Skip to content

Commit

Permalink
Make ImageData class public for custom image pull policies (#2585)
Browse files Browse the repository at this point in the history
* 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
3 people committed Apr 19, 2020
1 parent 84f422b commit b6cd9c8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
Expand Up @@ -10,7 +10,7 @@

@Value
@Builder
class ImageData {
public class ImageData {

@NonNull
Instant createdAt;
Expand Down
1 change: 1 addition & 0 deletions core/src/test/java/alt/testcontainers/README.md
@@ -0,0 +1 @@
Useful place for running tests that need to be outside of the `org.testcontainers` package.
@@ -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();
}
}

}

0 comments on commit b6cd9c8

Please sign in to comment.