From 47f4d1b033e5f04d04eb3f40d16ffc79ee6e916f Mon Sep 17 00:00:00 2001 From: gorelikov Date: Wed, 5 Apr 2017 23:24:12 +0300 Subject: [PATCH] Clean up following review comments --- .../testcontainers/DockerClientFactory.java | 4 ---- .../DockerClientFactoryTest.java | 21 ++++--------------- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/core/src/main/java/org/testcontainers/DockerClientFactory.java b/core/src/main/java/org/testcontainers/DockerClientFactory.java index c33c5d03b20..693571802ad 100644 --- a/core/src/main/java/org/testcontainers/DockerClientFactory.java +++ b/core/src/main/java/org/testcontainers/DockerClientFactory.java @@ -97,10 +97,6 @@ public DockerClient client() { " Total Memory: " + dockerInfo.getMemTotal() / (1024 * 1024) + " MB"); checkVersion(version.getVersion()); - - // Pull the image we use to perform some checks - checkAndPullImage(client, TINY_IMAGE); - checkDiskSpaceAndHandleExceptions(client); preconditionsChecked = true; } diff --git a/core/src/test/java/org/testcontainers/DockerClientFactoryTest.java b/core/src/test/java/org/testcontainers/DockerClientFactoryTest.java index 5f5dbe1ac3a..8b03e27ad81 100644 --- a/core/src/test/java/org/testcontainers/DockerClientFactoryTest.java +++ b/core/src/test/java/org/testcontainers/DockerClientFactoryTest.java @@ -8,39 +8,26 @@ import static org.junit.Assert.assertTrue; /** - * Created mgorelikov on 05/04/2017 * Test for {@link DockerClientFactory}. */ public class DockerClientFactoryTest { - private static final String SUCCESS = "SUCCESS"; - @Test - public void runCommandInsideDockerShouldPullImageIfItDoesNotExistsLocally() { + public void runCommandInsideDockerShouldNotFailIfImageDoesNotExistsLocally() { final DockerClientFactory dockFactory = DockerClientFactory.instance(); - final String imageName = TestcontainersConfiguration.getInstance().getTinyImage(); //remove tiny image, so it will be pulled during next command run dockFactory.client() - .removeImageCmd(imageName) + .removeImageCmd(TestcontainersConfiguration.getInstance().getTinyImage()) .withForce(true).exec(); - String result = dockFactory.runInsideDocker( - cmd -> cmd.withCmd("sh", "-c", "echo '" + SUCCESS + "'"), + dockFactory.runInsideDocker( + cmd -> cmd.withCmd("sh", "-c", "echo 'SUCCESS'"), (client, id) -> client.logContainerCmd(id) .withStdOut(true) .exec(new LogToStringContainerCallback()) .toString() ); - //check local image availability - assertTrue(isImageAvailable(dockFactory, imageName)); - assertEquals(SUCCESS + '\n', result); - } - - private boolean isImageAvailable(DockerClientFactory dockFactory, String imageName) { - return !dockFactory.client().listImagesCmd() - .withImageNameFilter(imageName) - .exec().isEmpty(); } } \ No newline at end of file