Module
Core
Proposal
I would like to allow unversioned images like wiremock/wiremock:test if and only if compatibleSubstituteFor is explicitly set by the users. By default, IMHO the validation should fail, because we cannot compare against the minimum required version.
At the moment it is not possible, because there is no getter method for compatibleSubstituteFor
Sample code
public WireMockContainer(DockerImageName dockerImage) {
super(dockerImage);
dockerImage.assertCompatibleWith(new DockerImageName(OFFICIAL_IMAGE_NAME));
// Verify the minimum version for the official image
final ComparableVersion version = new ComparableVersion(dockerImage.getVersionPart());
if (!version.isSemanticVersion()) { // Accept only images when compatibility is declared explicitly
// TODO: We cannot extract compatibleSubstituteFor from Testcontainers API
} else {
boolean isLessThanBaseVersion = version.isLessThan(WIREMOCK_2_MINIMUM_SUPPORTED_VERSION);
if (OFFICIAL_IMAGE_NAME.equals(dockerImage.getUnversionedPart()) && isLessThanBaseVersion) {
throw new IllegalArgumentException("For the official image, the WireMock version must be >= " + WIREMOCK_2_MINIMUM_SUPPORTED_VERSION);
}
}
// ...
Sample Test
@Test
@Disabled("Requires https://github.com/testcontainers/testcontainers-java/issues/7305")
public void shouldFailForUnversionedImage() {
IllegalStateException ex = Assertions.assertThrows(IllegalStateException.class, () -> {
WireMockContainer container = new WireMockContainer(
new DockerImageName(WireMockContainer.OFFICIAL_IMAGE_NAME, "test"));
});
assertThat(ex.getMessage())
.as("Wrong exception message")
.contains("Failed to verify that image")
.contains("is a compatible substitute for '" + WireMockContainer.OFFICIAL_IMAGE_NAME + "'");
}
Module
Core
Proposal
I would like to allow unversioned images like
wiremock/wiremock:testif and only ifcompatibleSubstituteForis explicitly set by the users. By default, IMHO the validation should fail, because we cannot compare against the minimum required version.At the moment it is not possible, because there is no getter method for
compatibleSubstituteForSample code
Sample Test