Skip to content
Merged
Show file tree
Hide file tree
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
Expand Up @@ -155,6 +155,11 @@ protected String getDescription() {
configuredInstance.getDescription()
);
}

@Override
public String toString() {
return getDescription();
}
}

private static class NoopImageNameSubstitutor extends ImageNameSubstitutor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
import org.junit.Rule;
import org.junit.Test;
import org.mockito.Mockito;
import org.testcontainers.containers.GenericContainer;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.eq;

public class ImageNameSubstitutorTest {
Expand Down Expand Up @@ -64,4 +66,19 @@ public void testWorksWithoutConfiguredImplementation() {
.as("the image has been substituted by default then configured implementations")
.isEqualTo("substituted-image:latest");
}

@Test
public void testImageNameSubstitutorToString() {
Mockito
.doReturn(FakeImageSubstitutor.class.getCanonicalName())
.when(TestcontainersConfiguration.getInstance())
.getImageSubstitutorClassName();

try (GenericContainer<?> container = new GenericContainer<>(DockerImageName.parse("original"))) {
assertThatThrownBy(container::start)
.hasMessageContaining(
"imageNameSubstitutor=Chained substitutor of 'default implementation' and then 'test implementation'"
);
}
}
}