@Test public void checkImagesAreFoundCorrectly() { Assert.assertNull(DockerUtils.findImageByIdOrByTag("oops81:unknown", this.docker)); Assert.assertNotNull(DockerUtils.findImageByIdOrByTag("ubuntu", this.docker)); Assert.assertNotNull(DockerUtils.findImageByIdOrByTag("ubuntu:latest", this.docker)); }
@Test public void testDockerUtils_onLimits() { DockerUtils.deleteImageIfItExists(null, this.docker); Assert.assertTrue("No exception is thrown trying to delete a null image ID.", true); DockerUtils.deleteImageIfItExists("bla 11 4 2 bla", this.docker); Assert.assertTrue( "No exception is thrown trying to delete something that does not exist.", true); Container container = DockerUtils.findContainerByIdOrByName("bla 11 4 2 bla", this.docker); Assert.assertNull(container); Image image = DockerUtils.findImageByIdOrByTag(null, this.docker); Assert.assertNull(image); image = DockerUtils.findImageByIdOrByTag("invalid", this.docker); Assert.assertNull(image); }
@Test(expected = TargetException.class) public void testConfigureVM_invalidBaseImage() throws Exception { Assume.assumeTrue(this.dockerIsInstalled); Map<String, String> targetProperties = loadTargetProperties(); targetProperties.put(DockerHandler.IMAGE_ID, "will-not-be-generated"); targetProperties.put(DockerHandler.BASE_IMAGE, "oops81:unknown"); DockerMachineConfigurator configurator = new DockerMachineConfigurator( targetProperties, this.msgCfg, "656sdf6sd", "/test", "app", new Instance()); try { configurator.dockerClient = this.docker; configurator.createImage("will-not-be-generated"); } finally { configurator.dockerClient = null; configurator.close(); Assert.assertNull(DockerUtils.findImageByIdOrByTag("will-not-be-generated", this.docker)); } }