public async Task Entrypoint() { // Given var testcontainersBuilder = new TestcontainersBuilder <TestcontainersContainer>() .WithImage("alpine") .WithEntrypoint("/bin/sh", "-c", "exit 255"); // When // Then await using (ITestcontainersContainer testcontainer = testcontainersBuilder.Build()) { await testcontainer.StartAsync(); Assert.Equal(255, await testcontainer.GetExitCode()); } }
public async Task WorkingDirectory() { // Given var testcontainersBuilder = new TestcontainersBuilder <TestcontainersContainer>() .WithImage("alpine") .WithEntrypoint("/bin/sh", "-c", "test -d /tmp && exit $? || exit $?") .WithWorkingDirectory("/tmp"); // When // Then await using (ITestcontainersContainer testcontainer = testcontainersBuilder.Build()) { await testcontainer.StartAsync(); Assert.Equal(0, await testcontainer.GetExitCode()); } }
public async Task Hostname() { // Given const string hostname = "alpine"; // When var testcontainersBuilder = new TestcontainersBuilder <TestcontainersContainer>() .WithImage("alpine") .WithEntrypoint("/bin/sh", "-c", $"hostname | grep '{hostname}' &> /dev/null") .WithHostname(hostname); // Then await using (ITestcontainersContainer testcontainer = testcontainersBuilder.Build()) { await testcontainer.StartAsync(); Assert.Equal(0, await testcontainer.GetExitCode()); } }