File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
main/java/org/testcontainers/utility
test/java/org/testcontainers/utility Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -155,6 +155,11 @@ protected String getDescription() {
155155 configuredInstance .getDescription ()
156156 );
157157 }
158+
159+ @ Override
160+ public String toString () {
161+ return getDescription ();
162+ }
158163 }
159164
160165 private static class NoopImageNameSubstitutor extends ImageNameSubstitutor {
Original file line number Diff line number Diff line change 55import org .junit .Rule ;
66import org .junit .Test ;
77import org .mockito .Mockito ;
8+ import org .testcontainers .containers .GenericContainer ;
89
910import static org .assertj .core .api .Assertions .assertThat ;
11+ import static org .assertj .core .api .Assertions .assertThatThrownBy ;
1012import static org .mockito .ArgumentMatchers .eq ;
1113
1214public class ImageNameSubstitutorTest {
@@ -64,4 +66,19 @@ public void testWorksWithoutConfiguredImplementation() {
6466 .as ("the image has been substituted by default then configured implementations" )
6567 .isEqualTo ("substituted-image:latest" );
6668 }
69+
70+ @ Test
71+ public void testImageNameSubstitutorToString () {
72+ Mockito
73+ .doReturn (FakeImageSubstitutor .class .getCanonicalName ())
74+ .when (TestcontainersConfiguration .getInstance ())
75+ .getImageSubstitutorClassName ();
76+
77+ try (GenericContainer <?> container = new GenericContainer <>(DockerImageName .parse ("original" ))) {
78+ assertThatThrownBy (container ::start )
79+ .hasMessageContaining (
80+ "imageNameSubstitutor=Chained substitutor of 'default implementation' and then 'test implementation'"
81+ );
82+ }
83+ }
6784}
You can’t perform that action at this time.
0 commit comments