Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump to .Net 8 + Update Nuget Packages to non vulnerable version #278

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion tests/core/Statiq.Common.Tests/Meta/MetadataFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public void ReturnsFalseForInvalidValue()

// Then
Assert.That(contains, Is.False);
Assert.That(value, Is.EquivalentTo(null));
Assert.That(value, Is.Null);
}

[Test]
Expand Down
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was an actual mistake by me in translating the "old" asserts into the "new" - so corrected.

Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public async Task CopyFilesInTopDirectoryOnly()
// Then
Assert.That(context.FileSystem.GetOutputFile("test-a.txt").Exists, Is.True);
Assert.That(context.FileSystem.GetOutputFile("test-b.txt").Exists, Is.True);
Assert.That(context.FileSystem.GetOutputFile("Subfolder/test-c.txt").Exists, Is.True);
Assert.That(context.FileSystem.GetOutputFile("Subfolder/test-c.txt").Exists, Is.False);
Assert.That(context.FileSystem.GetOutputDirectory("Subfolder").Exists, Is.False);
Assert.That(context.FileSystem.GetOutputFile("markdown-x.md").Exists, Is.False);
Assert.That(context.FileSystem.GetOutputFile("Subfolder/markdown-y.md").Exists, Is.False);
Expand Down
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically Struct is actually more correct, but seems that prior frameworks reported SpecificKind as Structure.

Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ enum Yellow
// Then
results.Single(x => x["Name"].Equals("Green"))["SpecificKind"].ShouldBe("Class");
results.Single(x => x["Name"].Equals("Blue"))["SpecificKind"].ShouldBe("Class");
results.Single(x => x["Name"].Equals("Red"))["SpecificKind"].ShouldBe("Structure");
results.Single(x => x["Name"].Equals("Red"))["SpecificKind"].ShouldBe("Struct");
results.Single(x => x["Name"].Equals("Yellow"))["SpecificKind"].ShouldBe("Enum");
}

Expand Down
34 changes: 17 additions & 17 deletions tests/extensions/Statiq.Handlebars.Tests/RenderHandlebarsFixture.cs
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With more recent Handlebars version, the BlockHelper needs to be started by # - can be seen in the official handlebars repository. ⚠️ CAUTION: This is likely to be a breaking change to prior Statiq.Framework users - but would make sense to follow the "official" handlebars behaviour

Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public async Task RendersHandlebarsWithBlockHelper()
{
// Given
const string input = @"{{#each animals}}
The animal, {{name}}, {{StringEqualityBlockHelper type 'dog'}}is a dog{{else}}is not a dog{{/StringEqualityBlockHelper}}.
The animal, {{name}}, {{#StringEqualityBlockHelper type 'dog'}}is a dog{{else}}is not a dog{{/StringEqualityBlockHelper}}.
{{/each}}";
const string output = @"The animal, Fluffy, is not a dog.
The animal, Fido, is a dog.
Expand Down Expand Up @@ -324,7 +324,7 @@ public async Task RendersHandlebarsWithBlockHelperUsingConfigure()
{
// Given
const string input = @"{{#each animals}}
The animal, {{name}}, {{StringEqualityBlockHelper type 'dog'}}is a dog{{else}}is not a dog{{/StringEqualityBlockHelper}}.
The animal, {{name}}, {{#StringEqualityBlockHelper type 'dog'}}is a dog{{else}}is not a dog{{/StringEqualityBlockHelper}}.
{{/each}}";
const string output = @"The animal, Fluffy, is not a dog.
The animal, Fido, is a dog.
Expand All @@ -346,22 +346,22 @@ public async Task RendersHandlebarsWithBlockHelperUsingConfigure()

RenderHandlebars handlebars = new RenderHandlebars()
.Configure((_, __, x) => x.RegisterHelper("StringEqualityBlockHelper", (writer, options, __, arguments) =>
{
if (arguments.Length != 2)
{
if (arguments.Length != 2)
{
throw new HandlebarsException("{{StringEqualityBlockHelper}} helper must have exactly two argument");
}
string left = arguments[0] as string;
string right = arguments[1] as string;
if (left == right)
{
options.Template(writer, null);
}
else
{
options.Inverse(writer, null);
}
}));
throw new HandlebarsException("{{StringEqualityBlockHelper}} helper must have exactly two argument");
}
string left = arguments[0] as string;
string right = arguments[1] as string;
if (left == right)
{
options.Template(writer, null);
}
else
{
options.Inverse(writer, null);
}
}));

// When
TestDocument result = await ExecuteAsync(document, handlebars).SingleAsync();
Expand Down
11 changes: 10 additions & 1 deletion tests/extensions/Statiq.Lunr.Tests/GenerateLunrIndexFixture.cs
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied Globalization on TestFixture, however only two tests had been affected on my local machine by the coma seperator due to german localization.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand All @@ -14,6 +15,14 @@ namespace Statiq.Lunr.Tests
[TestFixture]
public class GenerateLunrIndexFixture : BaseFixture
{
[SetUp]
public void SetUp()
{
// Set the culture to en-US for the tests, otherwise tests with decimals fail on machines with , as decimal seperator
CultureInfo.CurrentCulture = new CultureInfo("en-US");
CultureInfo.CurrentUICulture = new CultureInfo("en-US");
}

public class ExecuteTests : GenerateLunrIndexFixture
{
[Test]
Expand Down Expand Up @@ -541,7 +550,7 @@ public async Task ConvertsSearchableField(object value, string expected)

// Then
TestDocument indexDocument = results.ShouldHaveSingleWithDestination(GenerateLunrIndex.DefaultScriptPath.ChangeExtension(".index.json"));
indexDocument.Content.ShouldContain(expected);
indexDocument.Content.ShouldContainWithoutWhitespace(expected); // ShouldContain is clipped to first 100 chars, but occurrence is beyond. This method is not clipped; Workaround
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a little more tricky - ShouldContain is (now?) clipped to 100 chars and the match is actually in the testdocument content - however all further text is cut-off with "..." as such the test fails. ShouldContainWithoutWhitespace is the only extension method, which is not clipping the actual. Tried to explain through comment, so it's not reversed as it's not very "intuitive"

}

[Test]
Expand Down
Loading