Skip to content

Commit b868a4a

Browse files
committed
Fix test to ensure it loads a valid yaml test file and asserts its output
1 parent e3e6e4d commit b868a4a

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

docs/source/elastic/reference/kibana-alerting-action-settings.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ groups:
3333
default: an empty list
3434
platforms:
3535
- cloud
36+
# language=markdown
3637
example: |
3738
In the following example, two custom host settings
3839
are defined. The first provides a custom host setting for mail server

tests/Elastic.Markdown.Tests/SettingsInclusion/IncludeTests.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
using System.IO.Abstractions.TestingHelpers;
66
using Elastic.Markdown.Diagnostics;
7+
using Elastic.Markdown.IO;
78
using Elastic.Markdown.Myst.Directives;
89
using Elastic.Markdown.Tests.Directives;
910
using FluentAssertions;
@@ -12,28 +13,33 @@
1213
namespace Elastic.Markdown.Tests.SettingsInclusion;
1314

1415
public class IncludeTests(ITestOutputHelper output) : DirectiveTest<SettingsBlock>(output,
15-
"""
16-
```{settings} _snippets/test.md
16+
$$"""
17+
```{settings} /{{SettingsPath.Replace("docs/source/", "")}}
1718
```
1819
"""
1920
)
2021
{
22+
private static readonly string SettingsPath =
23+
"docs/source/elastic/reference/kibana-alerting-action-settings.yml";
24+
2125
protected override void AddToFileSystem(MockFileSystem fileSystem)
2226
{
27+
var realSettingsPath = Path.Combine(Paths.Root.FullName, SettingsPath);
2328
// language=markdown
24-
var inclusion = "*Hello world*";
25-
fileSystem.AddFile(@"docs/source/_snippets/test.md", inclusion);
29+
var inclusion = System.IO.File.ReadAllText(realSettingsPath);
30+
fileSystem.AddFile(SettingsPath, inclusion);
2631
}
2732

2833
[Fact]
2934
public void ParsesBlock() => Block.Should().NotBeNull();
3035

36+
[Fact]
37+
public void HasNoErrors() => Collector.Diagnostics.Should().BeEmpty();
38+
3139
[Fact]
3240
public void IncludesInclusionHtml() =>
3341
Html.Should()
34-
.Contain("Hello world")
35-
.And.Be("<p><em>Hello world</em></p>\n")
36-
;
42+
.Contain("xpack.encryptedSavedObjects.encryptionKey");
3743
}
3844
public class RandomFileEmitsAnError(ITestOutputHelper output) : DirectiveTest<SettingsBlock>(output,
3945
"""

0 commit comments

Comments
 (0)