Skip to content

Commit dfc2660

Browse files
Reorganize snapshots (#3790)
Reorganize the snapshots to remove the TFM from the file names and instead move to subdirectories that are easier to maintain when new TFMs are added.
1 parent 7ff4534 commit dfc2660

File tree

471 files changed

+29
-41
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

471 files changed

+29
-41
lines changed

test/Swashbuckle.AspNetCore.IntegrationTests/CodeGenerationTests.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ public static TheoryData<ClientGeneratorTool, string> SnapshotTestCases()
2121
var path = testCase.Data.Item1;
2222
var documentVersion = testCase.Data.Item2;
2323

24-
// Deduplicate by ignoring snapshots for other TFMs
25-
if (!path.EndsWith(".DotNet10_0.verified.txt", StringComparison.Ordinal))
26-
{
27-
continue;
28-
}
29-
3024
var version = documentVersion switch
3125
{
3226
{ Major: 2 } => OpenApiSpecVersion.OpenApi2_0,
@@ -78,7 +72,7 @@ await VerifyDirectory(
7872
pattern: "*.cs",
7973
include: (p) => !p.Contains("bin") && !p.Contains("obj"),
8074
options: new() { RecurseSubdirectories = true })
81-
.UseDirectory("snapshots")
75+
.UseDirectory("snapshots/code")
8276
.UseFileName($"{nameof(GeneratesValidClient)}_{hashString}")
8377
.AddScrubber((builder) =>
8478
{

test/Swashbuckle.AspNetCore.IntegrationTests/SnapshotTestData.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@ public static class SnapshotTestData
1111
.First((p) => p.Key is "ProjectRoot")
1212
.Value!;
1313

14-
public static string SnapshotsPath() => Path.Combine(_projectRoot, "snapshots");
14+
public static string SnapshotsDirectory { get; } = $"snapshots/{Environment.Version.Major}_{Environment.Version.Minor}";
15+
16+
public static string SnapshotsPath() => Path.Combine(_projectRoot, "snapshots", $"{Environment.Version.Major}_{Environment.Version.Minor}");
1517

1618
public static string SchemasPath() => Path.Combine(_projectRoot, "schemas");
1719

1820
public static TheoryData<string, Version> Snapshots()
1921
{
2022
var testCases = new TheoryData<string, Version>();
21-
var snapshotsPath = Path.Combine(_projectRoot, "snapshots");
23+
var snapshotsPath = Path.Combine(_projectRoot, "snapshots", $"{Environment.Version.Major}_{Environment.Version.Minor}");
2224

2325
foreach (var path in Directory.EnumerateFiles(snapshotsPath, "*.txt", SearchOption.AllDirectories))
2426
{

test/Swashbuckle.AspNetCore.IntegrationTests/VerifyTests.cs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ namespace Swashbuckle.AspNetCore.IntegrationTests;
66
[Collection("TestSite")]
77
public partial class VerifyTests(ITestOutputHelper outputHelper)
88
{
9+
private static string SnapshotsDirectory { get; } = SnapshotTestData.SnapshotsDirectory;
10+
911
[Theory]
1012
[InlineData(typeof(Basic.Startup), "/swagger/v1/swagger.json")]
1113
[InlineData(typeof(NSwagClientExample.Startup), "/swagger/v1/swagger.json")]
@@ -31,9 +33,8 @@ public async Task SwaggerEndpoint_ReturnsValidSwaggerJson(
3133
var swagger = await swaggerResponse.Content.ReadAsStringAsync(TestContext.Current.CancellationToken);
3234

3335
await Verify(NormalizeLineBreaks(swagger))
34-
.UseDirectory("snapshots")
35-
.UseParameters(startupType, GetVersion(swaggerRequestUri))
36-
.UniqueForTargetFrameworkAndVersion();
36+
.UseDirectory(SnapshotsDirectory)
37+
.UseParameters(startupType, GetVersion(swaggerRequestUri));
3738
}
3839

3940
[Fact]
@@ -49,9 +50,8 @@ public async Task SwaggerEndpoint_ReturnsValidSwaggerJson_ForAutofaq()
4950
var swagger = await swaggerResponse.Content.ReadAsStringAsync(TestContext.Current.CancellationToken);
5051

5152
await Verify(swagger)
52-
.UseDirectory("snapshots")
53-
.UseParameters(startupType, GetVersion(swaggerRequestUri))
54-
.UniqueForTargetFrameworkAndVersion();
53+
.UseDirectory(SnapshotsDirectory)
54+
.UseParameters(startupType, GetVersion(swaggerRequestUri));
5555
}
5656

5757
[Theory]
@@ -69,9 +69,8 @@ public async Task Swagger_IsValidJson_No_Startup(
6969
var swaggerResponse = await SwaggerEndpointReturnsValidSwaggerJson(entryPointType, swaggerRequestUri);
7070

7171
await Verify(swaggerResponse)
72-
.UseDirectory("snapshots")
73-
.UseParameters(entryPointType, GetVersion(swaggerRequestUri))
74-
.UniqueForTargetFrameworkAndVersion();
72+
.UseDirectory(SnapshotsDirectory)
73+
.UseParameters(entryPointType, GetVersion(swaggerRequestUri));
7574
}
7675

7776
[Fact]
@@ -82,9 +81,7 @@ public async Task TypesAreRenderedCorrectly()
8281

8382
var swaggerResponse = await SwaggerResponse(client, "/swagger/v1/swagger.json");
8483

85-
await Verify(swaggerResponse)
86-
.UseDirectory("snapshots")
87-
.UniqueForTargetFrameworkAndVersion();
84+
await Verify(swaggerResponse).UseDirectory(SnapshotsDirectory);
8885
}
8986

9087
private static async Task<string> SwaggerEndpointReturnsValidSwaggerJson(Type entryPointType, string swaggerRequestUri)

test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/VerifyTests.SwaggerEndpoint_ReturnsValidSwaggerJson_ForAutofaq.DotNet10_0.verified.txt renamed to test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/10_0/VerifyTests.SwaggerEndpoint_ReturnsValidSwaggerJson_ForAutofaq.verified.txt

File renamed without changes.

test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/VerifyTests.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=Basic.Startup_swaggerRequestUri=v1.DotNet10_0.verified.txt renamed to test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/10_0/VerifyTests.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=Basic.Startup_swaggerRequestUri=v1.verified.txt

File renamed without changes.

test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/VerifyTests.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CliExample.Startup_swaggerRequestUri=v1.DotNet10_0.verified.txt renamed to test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/10_0/VerifyTests.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CliExample.Startup_swaggerRequestUri=v1.verified.txt

File renamed without changes.

test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/VerifyTests.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=ConfigFromFile.Startup_swaggerRequestUri=v1.DotNet10_0.verified.txt renamed to test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/10_0/VerifyTests.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=ConfigFromFile.Startup_swaggerRequestUri=v1.verified.txt

File renamed without changes.

test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/VerifyTests.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CustomDocumentSerializer.Startup_swaggerRequestUri=v1.DotNet10_0.verified.txt renamed to test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/10_0/VerifyTests.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CustomDocumentSerializer.Startup_swaggerRequestUri=v1.verified.txt

File renamed without changes.

test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/VerifyTests.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CustomUIConfig.Startup_swaggerRequestUri=v1.DotNet10_0.verified.txt renamed to test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/10_0/VerifyTests.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CustomUIConfig.Startup_swaggerRequestUri=v1.verified.txt

File renamed without changes.

test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/VerifyTests.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CustomUIIndex.Startup_swaggerRequestUri=v1.DotNet10_0.verified.txt renamed to test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/10_0/VerifyTests.SwaggerEndpoint_ReturnsValidSwaggerJson_startupType=CustomUIIndex.Startup_swaggerRequestUri=v1.verified.txt

File renamed without changes.

0 commit comments

Comments
 (0)