diff --git a/tests/Testcontainers.Platform.Linux.Tests/TarOutputMemoryStreamTest.cs b/tests/Testcontainers.Platform.Linux.Tests/TarOutputMemoryStreamTest.cs index 43f2d14af..1f89c5010 100644 --- a/tests/Testcontainers.Platform.Linux.Tests/TarOutputMemoryStreamTest.cs +++ b/tests/Testcontainers.Platform.Linux.Tests/TarOutputMemoryStreamTest.cs @@ -109,8 +109,8 @@ public async Task TestFileExistsInContainer() .WithImage(CommonImages.Alpine) .WithEntrypoint(CommonCommands.SleepInfinity) .WithResourceMapping(_testFile, new FileInfo(targetFilePath1)) - .WithResourceMapping(_testFile, targetDirectoryPath1) - .WithResourceMapping(_testFile.Directory, targetDirectoryPath2) + .WithResourceMapping(_testFile.FullName, targetDirectoryPath1) + .WithResourceMapping(_testFile.Directory.FullName, targetDirectoryPath2) .Build(); // When @@ -123,10 +123,10 @@ await container.StartAsync() await container.CopyAsync(fileContent, targetFilePath2) .ConfigureAwait(false); - await container.CopyAsync(_testFile, targetDirectoryPath3) + await container.CopyAsync(_testFile.FullName, targetDirectoryPath3) .ConfigureAwait(false); - await container.CopyAsync(_testFile.Directory, targetDirectoryPath4) + await container.CopyAsync(_testFile.Directory.FullName, targetDirectoryPath4) .ConfigureAwait(false); // Then diff --git a/tests/Testcontainers.Tests/Unit/Containers/Unix/TestcontainersContainerTest.cs b/tests/Testcontainers.Tests/Unit/Containers/Unix/TestcontainersContainerTest.cs index de3b6fd01..0b51fc4ac 100644 --- a/tests/Testcontainers.Tests/Unit/Containers/Unix/TestcontainersContainerTest.cs +++ b/tests/Testcontainers.Tests/Unit/Containers/Unix/TestcontainersContainerTest.cs @@ -158,7 +158,8 @@ public async Task StaticPortBinding() await using var container = new ContainerBuilder() .WithImage(CommonImages.Nginx) .WithPortBinding(hostPort, containerPort) - .WithWaitStrategy(Wait.ForUnixContainer().UntilPortIsAvailable(containerPort)) + .WithWaitStrategy(Wait.ForUnixContainer().UntilHttpRequestIsSucceeded(request => + request.ForPort(containerPort))) .Build(); // When @@ -178,7 +179,8 @@ public async Task RandomPortBinding() await using var container = new ContainerBuilder() .WithImage(CommonImages.Nginx) .WithPortBinding(containerPort, true) - .WithWaitStrategy(Wait.ForUnixContainer().UntilPortIsAvailable(containerPort)) + .WithWaitStrategy(Wait.ForUnixContainer().UntilHttpRequestIsSucceeded(request => + request.ForPort(containerPort))) .Build(); // When @@ -189,6 +191,24 @@ await container.StartAsync() Assert.NotEqual(containerPort, container.GetMappedPublicPort(containerPort)); } + [Fact] + public async Task UnboundPortBindingThrowsException() + { + // Given + await using var container = new ContainerBuilder() + .WithImage(CommonImages.Alpine) + .WithEntrypoint(CommonCommands.SleepInfinity) + .WithPortBinding(80, true) + .Build(); + + // When + await container.StartAsync() + .ConfigureAwait(false); + + // Then + Assert.Throws(() => container.GetMappedPublicPort(443)); + } + [Fact] public async Task BindMountAndCommand() {