Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make ImageData class public for custom image pull policies (#2585)
* Making imagedata public so it can be used to create custom image pull policies. Adding test to ensure it works as expected. * Ensuring we don't do unnecessary pulls and using the default generic container image for the out of package pull policy test. Co-authored-by: Chason Choate <chason.choate@digitalreasoning.com> Co-authored-by: Richard North <rich.north@gmail.com>
- Loading branch information
1 parent
84f422b
commit b6cd9c8
Showing
3 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
|
||
@Value | ||
@Builder | ||
class ImageData { | ||
public class ImageData { | ||
|
||
@NonNull | ||
Instant createdAt; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Useful place for running tests that need to be outside of the `org.testcontainers` package. |
27 changes: 27 additions & 0 deletions
27
core/src/test/java/alt/testcontainers/images/OutOfPackageImagePullPolicyTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package alt.testcontainers.images; | ||
|
||
import org.junit.Test; | ||
import org.testcontainers.containers.GenericContainer; | ||
import org.testcontainers.containers.startupcheck.OneShotStartupCheckStrategy; | ||
import org.testcontainers.images.AbstractImagePullPolicy; | ||
import org.testcontainers.images.ImageData; | ||
import org.testcontainers.utility.DockerImageName; | ||
|
||
public class OutOfPackageImagePullPolicyTest { | ||
@Test | ||
public void shouldSupportCustomPoliciesOutOfTestContainersPackage() { | ||
try ( | ||
GenericContainer<?> container = new GenericContainer<>() | ||
.withImagePullPolicy(new AbstractImagePullPolicy() { | ||
@Override | ||
protected boolean shouldPullCached(DockerImageName imageName, ImageData localImageData) { | ||
return false; | ||
} | ||
}) | ||
) { | ||
container.withStartupCheckStrategy(new OneShotStartupCheckStrategy()); | ||
container.start(); | ||
} | ||
} | ||
|
||
} |