testcontainers / testcontainers/testcontainers-java
[Enhancement]: Expose `compatibleSubstituteFor()` through API
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Java
- Sterne
- 8.7k
- Forks
- 1.9k
- Ø Merge
- 2 T. 17 Std.
- Gemergte PRs (30 T.)
- 9
Beschreibung
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 + "'");
}
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit den im Issue gezeigten DockerImageName- und compatibleSubstituteFor/assertCompatibleWith-API-Pfaden und suche anschließend die zugehörigen Tests. Mache den explizit konfigurierten kompatiblen Ersatz sichtbar und aktiviere den deaktivierten WireMockContainer-Test, sobald er die erwartete Fehlermeldung verifizieren kann.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- docker, java
- Bereich
- api
- Issue-Typ
- Feature
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100