Skip to content

Commit

Permalink
fix for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
StefH committed Jan 27, 2025
1 parent 547b805 commit b06c478
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/WireMock.Net.TestcontainersExample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ private static async Task TestAsync(string? image = null)
var dummyNetwork = new NetworkBuilder()
.WithName($"Dummy Network for {image ?? "null"}")
.WithReuse(true)
.WithCleanUp(true)
// .WithCleanUp(true)
.Build();

var builder = new WireMockContainerBuilder()
Expand Down
9 changes: 8 additions & 1 deletion src/WireMock.Net.Testcontainers/WireMockContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,14 @@ private void WireMockContainer_Started(object sender, EventArgs e)

private async void FileCreatedChangedOrDeleted(object sender, FileSystemEventArgs args)
{
await ReloadStaticMappingsAsync(args.FullPath);
try
{
await ReloadStaticMappingsAsync(args.FullPath);
}
catch (Exception ex)
{
Logger.LogWarning(ex, "Error reloading static mappings from '{FullPath}'.", args.FullPath);
}
}

private async Task ReloadStaticMappingsAsync(string path, CancellationToken cancellationToken = default)
Expand Down
9 changes: 6 additions & 3 deletions test/WireMock.Net.Tests/Testcontainers/TestcontainersTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using FluentAssertions;
using FluentAssertions.Execution;
using WireMock.Net.Testcontainers;
using WireMock.Net.Testcontainers.Utils;
using WireMock.Net.Tests.Facts;
using Xunit;

Expand All @@ -26,7 +27,7 @@ public async Task WireMockContainer_Build_WithNoImage_TestGrpc1()
.WithCleanUp(true)
.WithAdminUserNameAndPassword(adminUsername, adminPassword)
.WithCommand("--UseHttp2")
.WithEntrypoint("./wiremock-net", "--Urls", "http://*:80", "grpc://*:9090")
.WithCommand("--Urls", "http://*:80 grpc://*:9090")
.WithPortBinding(9090, true)
.Build();

Expand Down Expand Up @@ -164,7 +165,8 @@ public async Task WireMockContainer_Build_WithImage_And_StartAsync_and_StopAsync
.WithCleanUp(true)
.WithAdminUserNameAndPassword(adminUsername, adminPassword);

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
var imageOS = await TestcontainersUtils.GetImageOSAsync.Value;
if (imageOS == OSPlatform.Windows)
{
wireMockContainerBuilder = wireMockContainerBuilder.WithWindowsImage();
}
Expand All @@ -189,7 +191,8 @@ public async Task WireMockContainer_Build_WithImageAsText_And_StartAsync_and_Sto
.WithCleanUp(true)
.WithAdminUserNameAndPassword(adminUsername, adminPassword);

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
var imageOS = await TestcontainersUtils.GetImageOSAsync.Value;
if (imageOS == OSPlatform.Windows)
{
wireMockContainerBuilder = wireMockContainerBuilder.WithImage("sheyenrath/wiremock.net-windows");
}
Expand Down

0 comments on commit b06c478

Please sign in to comment.