Skip to content

Leverage VerifyFile #9681

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -69,10 +69,8 @@ public async Task WhenUsedWithAzureContainerAppsEnvironment_RespectsStronglyType
app.Run();

var mainBicepPath = Path.Combine(tempDir.FullName, "main.bicep");
Assert.True(File.Exists(mainBicepPath));
var mainBicep = File.ReadAllText(mainBicepPath);

await Verify(mainBicep, "bicep");
await VerifyFile(mainBicepPath);

tempDir.Delete(recursive: true);
}
@@ -121,10 +119,8 @@ public async Task PublishAsync_GeneratesMainBicep_WithSnapshots()
app.Run();

var mainBicepPath = Path.Combine(tempDir.FullName, "main.bicep");
Assert.True(File.Exists(mainBicepPath));
var content = File.ReadAllText(mainBicepPath);

await Verify(content, extension: "bicep");
await VerifyFile(mainBicepPath);
}

[Fact]
28 changes: 6 additions & 22 deletions tests/Aspire.Hosting.Docker.Tests/DockerComposePublisherTests.cs
Original file line number Diff line number Diff line change
@@ -154,9 +154,8 @@ public async Task DockerComposeCorrectlyEmitsPortMappings()
await app.RunAsync().WaitAsync(TimeSpan.FromSeconds(60));

var composePath = Path.Combine(tempDir.Path, "docker-compose.yaml");
Assert.True(File.Exists(composePath));

await Verify(File.ReadAllText(composePath), "yaml");
await VerifyFile(composePath);
}

[Theory]
@@ -331,11 +330,8 @@ public async Task DockerComposeMapsPortsProperly()
app.Run();

var composePath = Path.Combine(tempDir.Path, "docker-compose.yaml");
Assert.True(File.Exists(composePath));

var composeFile = File.ReadAllText(composePath);

await Verify(composeFile);
await VerifyFile(composePath);
}

[Fact]
@@ -357,11 +353,8 @@ public async Task PublishAsync_WithDashboardEnabled_IncludesDashboardService()
app.Run();

var composePath = Path.Combine(tempDir.Path, "docker-compose.yaml");
Assert.True(File.Exists(composePath));

var composeContent = File.ReadAllText(composePath);

await Verify(composeContent, "yaml");
await VerifyFile(composePath);
}

[Fact]
@@ -383,11 +376,8 @@ public async Task PublishAsync_WithDashboardDisabled_DoesNotIncludeDashboardServ
app.Run();

var composePath = Path.Combine(tempDir.Path, "docker-compose.yaml");
Assert.True(File.Exists(composePath));

var composeContent = File.ReadAllText(composePath);

await Verify(composeContent, "yaml");
await VerifyFile(composePath);
}

[Fact]
@@ -411,11 +401,8 @@ public async Task PublishAsync_WithDashboard_UsesCustomConfiguration()
app.Run();

var composePath = Path.Combine(tempDir.Path, "docker-compose.yaml");
Assert.True(File.Exists(composePath));

var composeContent = File.ReadAllText(composePath);

await Verify(composeContent, "yaml");
await VerifyFile(composePath);
}

[Fact]
@@ -443,11 +430,8 @@ public async Task PublishAsync_MultipleResourcesWithOtlp_ConfiguresAllForDashboa
app.Run();

var composePath = Path.Combine(tempDir.Path, "docker-compose.yaml");
Assert.True(File.Exists(composePath));

var composeContent = File.ReadAllText(composePath);

await Verify(composeContent, "yaml");
await VerifyFile(composePath);
}

[Fact]
5 changes: 1 addition & 4 deletions tests/Aspire.Hosting.Docker.Tests/DockerComposeTests.cs
Original file line number Diff line number Diff line change
@@ -67,12 +67,9 @@ public async Task DockerComposeOnlyExposesExternalEndpoints()
app.Run();

var composeFile = Path.Combine(tempDir.FullName, "docker-compose.yaml");
Assert.True(File.Exists(composeFile), "Docker Compose file was not created.");

var composeContent = File.ReadAllText(composeFile);
await VerifyFile(composeFile);

await Verify(composeContent, "yaml");

tempDir.Delete(recursive: true);
}

Original file line number Diff line number Diff line change
@@ -97,11 +97,8 @@ public async Task PublishAppliesServiceCustomizations()

// Assert
var deploymentPath = Path.Combine(tempDir.Path, "templates/service/deployment.yaml");
Assert.True(File.Exists(deploymentPath));

var content = await File.ReadAllTextAsync(deploymentPath);

await Verify(content, "yaml");
await VerifyFile(deploymentPath);
}

private sealed class TestProject : IProjectMetadata
2 changes: 1 addition & 1 deletion tests/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -22,6 +22,6 @@
<PackageVersion Include="Testcontainers.Milvus" Version="$(TestcontainersPackageVersion)" />
<PackageVersion Include="Testcontainers.Oracle" Version="$(TestcontainersPackageVersion)" />
<PackageVersion Include="Testcontainers" Version="$(TestcontainersPackageVersion)" />
<PackageVersion Include="Verify.XunitV3" Version="30.3.0" />
<PackageVersion Include="Verify.XunitV3" Version="30.3.1" />
</ItemGroup>
</Project>
Loading
Oops, something went wrong.