Skip to content

Commit 906d9d3

Browse files
authored
Fix tests on Windows (#8747)
1 parent 8997e28 commit 906d9d3

File tree

6 files changed

+15
-12
lines changed

6 files changed

+15
-12
lines changed

src/CookieCrumble/src/CookieCrumble/Snapshot.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,11 @@ private static bool MatchSnapshot(
505505
{
506506
if (OperatingSystem.IsWindows())
507507
{
508-
// Normalize escaped line endings
509-
after = after.Replace("\\r\\n", "\\n");
508+
// Normalize escaped line endings if the expected value does not explicitly contain them.
509+
if (!before.Contains("\\r\\n", StringComparison.Ordinal))
510+
{
511+
after = after.Replace("\\r\\n", "\\n");
512+
}
510513
}
511514

512515
var diff = InlineDiffBuilder.Diff(before, after);

src/HotChocolate/AspNetCore/test/AspNetCore.Tests/HttpGetSchemaMiddlewareTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ public async Task Download_GraphQL_Schema(string path)
5454

5555
// assert
5656
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
57+
response.Headers.Remove("ETag");
58+
response.Content.Headers.ContentLength = null;
5759

5860
response.MatchMarkdownSnapshot();
5961
}
@@ -81,6 +83,8 @@ public async Task Download_GraphQL_Schema_Slicing_Args_Enabled(string path)
8183

8284
// assert
8385
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
86+
response.Headers.Remove("ETag");
87+
response.Content.Headers.ContentLength = null;
8488

8589
response.MatchMarkdownSnapshot();
8690
}

src/HotChocolate/AspNetCore/test/AspNetCore.Tests/__snapshots__/HttpGetSchemaMiddlewareTests.Download_GraphQL_Schema.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22

33
```text
44
Headers:
5-
ETag: "1-9lT+j9S1VOCU5XKHoaNVEuxjYrB+yk/yPGmxKIktwoY="
65
Cache-Control: public, must-revalidate, max-age=3600
76
Content-Type: application/graphql; charset=utf-8
87
Content-Disposition: attachment; filename="schema.graphql"
98
Last-Modified: Fri, 01 Jan 2021 00:00:00 GMT
10-
Content-Length: 7466
119
-------------------------->
1210
Status Code: OK
1311
-------------------------->

src/HotChocolate/AspNetCore/test/AspNetCore.Tests/__snapshots__/HttpGetSchemaMiddlewareTests.Download_GraphQL_Schema_Slicing_Args_Enabled.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22

33
```text
44
Headers:
5-
ETag: "1-273kV/JyKVpBuGqgpSjbHzLG6jb6xKsQlr4kTrMaNmg="
65
Cache-Control: public, must-revalidate, max-age=3600
76
Content-Type: application/graphql; charset=utf-8
87
Content-Disposition: attachment; filename="schema.graphql"
98
Last-Modified: Fri, 01 Jan 2021 00:00:00 GMT
10-
Content-Length: 7398
119
-------------------------->
1210
Status Code: OK
1311
-------------------------->

src/HotChocolate/MongoDb/test/Types.MongoDb/BsonTypeTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,18 +187,18 @@ public async Task Output_Should_MatchSnapshot_When_Value(string fieldName)
187187

188188
[Theory]
189189
[InlineData("int", "42", typeof(BsonInt64))]
190-
[InlineData("long", long.MaxValue, typeof(BsonInt64))]
190+
[InlineData("long", "9223372036854775807", typeof(BsonInt64))]
191191
[InlineData(
192192
"decimal",
193193
"\"42.1234\"",
194194
typeof(BsonString))] // we do not know that it should be a BsonDecimal
195-
[InlineData("double", 43.23, typeof(BsonDouble))]
196-
[InlineData("boolean", true, typeof(BsonBoolean))]
195+
[InlineData("double", "43.23", typeof(BsonDouble))]
196+
[InlineData("boolean", "true", typeof(BsonBoolean))]
197197
[InlineData("array", "[true, false]", typeof(BsonArray))]
198198
[InlineData("string", "\"string\"", typeof(BsonString))]
199199
public async Task Input_Should_MatchSnapshotAndType_When_Passed(
200200
string fieldName,
201-
object value,
201+
string value,
202202
Type type)
203203
{
204204
// arrange
@@ -220,7 +220,7 @@ public async Task Input_Should_MatchSnapshotAndType_When_Passed(
220220
.BuildRequestExecutorAsync();
221221

222222
// act
223-
await executor.ExecuteAsync($"{{ in(val:{value.ToString()!.ToLower()}) }}");
223+
await executor.ExecuteAsync($"{{ in(val:{value}) }}");
224224

225225
// assert
226226
Assert.NotEqual("INVALID", res);

src/HotChocolate/Primitives/test/Primitives.Tests/NameUtilsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public void InvalidName(string name)
1717
$"`{name}` is not a valid GraphQL name.{Environment.NewLine}"
1818
+ $"https://spec.graphql.org/October2021/#sec-Names{Environment.NewLine}"
1919
+ $" (Parameter 'name')",
20-
message);
20+
message.ReplaceLineEndings());
2121
}
2222

2323
[Theory]

0 commit comments

Comments
 (0)