Skip to content

Commit dce9a35

Browse files
authored
update more fsharp nullable warnings which are noisy on CI (#1972)
* update more fsharp nullable warnings which are noisy on CI * fix related warning
1 parent 863adca commit dce9a35

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

tests/Elastic.Markdown.Tests/Directives/AdmonitionTests.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ A regular paragraph.
170170
"""
171171
)
172172
{
173+
private readonly ITestOutputHelper _output = output;
174+
173175
[Fact]
174176
public void SetsCorrectAdmonitionType() => Block!.Admonition.Should().Be("dropdown");
175177

@@ -194,8 +196,8 @@ public void ContainsNestedDirective()
194196
{
195197
var html = Html;
196198
// Output the full HTML for inspection
197-
output.WriteLine("Generated HTML:");
198-
output.WriteLine(html);
199+
_output.WriteLine("Generated HTML:");
200+
_output.WriteLine(html);
199201

200202
html.Should().Contain("Nested Note");
201203
html.Should().Contain("This is a nested note with colons: 10:30 AM");

tests/authoring/Framework/MarkdownDocumentAssertions.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ module MarkdownDocumentAssertions =
3333
let matter = result.File.YamlFrontMatter
3434
match matter with
3535
| NonNull m ->
36-
match expectedAvailability with
37-
| NonNull a -> m.AppliesTo.Diagnostics <- a.Diagnostics
36+
match (expectedAvailability, m.AppliesTo) with
37+
| NonNull a, NonNull applies -> applies.Diagnostics <- a.Diagnostics
3838
| _ -> ()
3939

4040
let apply = m.AppliesTo

tests/authoring/FrontMatter/ProductsFrontMatter.fs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,19 @@ This is a test page without products frontmatter.
6969

7070
// Test that the file has the correct products
7171
test <@ defaultFile.File.YamlFrontMatter <> null @>
72-
test <@ defaultFile.File.YamlFrontMatter.Products <> null @>
73-
test <@ defaultFile.File.YamlFrontMatter.Products.Count = 2 @>
72+
match defaultFile.File.YamlFrontMatter with
73+
| NonNull yamlFrontMatter ->
74+
test <@ yamlFrontMatter.Products <> null @>
75+
match yamlFrontMatter.Products with
76+
| NonNull products ->
77+
test <@ products.Count = 2 @>
78+
// Test that the products are correctly identified
79+
let productIds = products |> Seq.map _.Id |> Set.ofSeq
80+
test <@ productIds.Contains("elasticsearch") @>
81+
test <@ productIds.Contains("ecctl") @>
82+
| _ -> ()
83+
| _ -> ()
7484

75-
// Test that the products are correctly identified
76-
let productIds = defaultFile.File.YamlFrontMatter.Products |> Seq.map (fun p -> p.Id) |> Set.ofSeq
77-
test <@ productIds.Contains("elasticsearch") @>
78-
test <@ productIds.Contains("ecctl") @>
7985

8086
[<Fact>]
8187
let ``does not include products in frontmatter when no products are specified`` () =
@@ -84,4 +90,10 @@ This is a test page without products frontmatter.
8490
let defaultFile = results.MarkdownResults |> Seq.find (fun r -> r.File.RelativePath = "index.md")
8591

8692
// Test that the file has no products
87-
test <@ defaultFile.File.YamlFrontMatter = null || defaultFile.File.YamlFrontMatter.Products = null || defaultFile.File.YamlFrontMatter.Products.Count = 0 @>
93+
match defaultFile.File.YamlFrontMatter with
94+
| NonNull frontMatter ->
95+
match frontMatter.Products with
96+
| NonNull products ->
97+
test <@ products.Count = 0 @>
98+
| _ -> ()
99+
| _ -> ()

0 commit comments

Comments
 (0)