Search in sources :

Example 1 with RemoveImageParams

use of org.eclipse.che.plugin.docker.client.params.RemoveImageParams in project che by eclipse.

the class DockerConnectorTest method shouldThrowDockerExceptionWhileRemovingImageIfResponseCodeIsNotSuccess.

@Test(expectedExceptions = DockerException.class, expectedExceptionsMessageRegExp = EXCEPTION_ERROR_MESSAGE)
public void shouldThrowDockerExceptionWhileRemovingImageIfResponseCodeIsNotSuccess() throws IOException {
    RemoveImageParams removeImageParams = RemoveImageParams.create(IMAGE);
    when(dockerResponse.getStatus()).thenReturn(RESPONSE_ERROR_CODE);
    dockerConnector.removeImage(removeImageParams);
    verify(dockerResponse).getStatus();
}
Also used : RemoveImageParams(org.eclipse.che.plugin.docker.client.params.RemoveImageParams) Test(org.testng.annotations.Test)

Example 2 with RemoveImageParams

use of org.eclipse.che.plugin.docker.client.params.RemoveImageParams in project che by eclipse.

the class DockerConnectorTest method shouldCallRemoveImageWithParametersObject.

@Test
public void shouldCallRemoveImageWithParametersObject() throws IOException {
    RemoveImageParams removeImageParams = RemoveImageParams.create(IMAGE);
    doNothing().when(dockerConnector).removeImage(removeImageParams);
    dockerConnector.removeImage(IMAGE);
    verify(dockerConnector).removeImage((RemoveImageParams) captor.capture());
    assertEquals(captor.getValue(), removeImageParams);
}
Also used : RemoveImageParams(org.eclipse.che.plugin.docker.client.params.RemoveImageParams) Test(org.testng.annotations.Test)

Example 3 with RemoveImageParams

use of org.eclipse.che.plugin.docker.client.params.RemoveImageParams in project che by eclipse.

the class DockerConnectorTest method shouldBeAbleToRemoveImage.

@Test
public void shouldBeAbleToRemoveImage() throws IOException {
    RemoveImageParams removeImageParams = RemoveImageParams.create(IMAGE);
    dockerConnector.removeImage(removeImageParams);
    verify(dockerConnectionFactory).openConnection(any(URI.class));
    verify(dockerConnection).method(REQUEST_METHOD_DELETE);
    verify(dockerConnection).path("/images/" + removeImageParams.getImage());
    verify(dockerConnection).request();
    verify(dockerResponse).getStatus();
}
Also used : RemoveImageParams(org.eclipse.che.plugin.docker.client.params.RemoveImageParams) URI(java.net.URI) Test(org.testng.annotations.Test)

Example 4 with RemoveImageParams

use of org.eclipse.che.plugin.docker.client.params.RemoveImageParams in project che by eclipse.

the class MachineProviderImplTest method shouldReTagBuiltImageWithPredictableOnInstanceCreationFromRecipe.

@Test
public void shouldReTagBuiltImageWithPredictableOnInstanceCreationFromRecipe() throws Exception {
    // given
    String repo = MACHINE_SNAPSHOT_PREFIX + "repo1";
    String tag = "tag1";
    String registry = "registry1";
    // when
    CheServiceImpl machine = createInstanceFromSnapshot(repo, tag, registry);
    // then
    TagParams tagParams = TagParams.create(registry + "/" + repo + ":" + tag, "eclipse-che/" + machine.getContainerName());
    verify(dockerConnector).tag(eq(tagParams));
    ArgumentCaptor<RemoveImageParams> argumentCaptor = ArgumentCaptor.forClass(RemoveImageParams.class);
    verify(dockerConnector).removeImage(argumentCaptor.capture());
    RemoveImageParams imageParams = argumentCaptor.getValue();
    assertEquals(imageParams.getImage(), registry + "/" + repo + ":" + tag);
    assertFalse(imageParams.isForce());
}
Also used : CheServiceImpl(org.eclipse.che.api.environment.server.model.CheServiceImpl) TagParams(org.eclipse.che.plugin.docker.client.params.TagParams) Matchers.anyString(org.mockito.Matchers.anyString) RemoveImageParams(org.eclipse.che.plugin.docker.client.params.RemoveImageParams) Test(org.testng.annotations.Test)

Aggregations

RemoveImageParams (org.eclipse.che.plugin.docker.client.params.RemoveImageParams)4 Test (org.testng.annotations.Test)4 URI (java.net.URI)1 CheServiceImpl (org.eclipse.che.api.environment.server.model.CheServiceImpl)1 TagParams (org.eclipse.che.plugin.docker.client.params.TagParams)1 Matchers.anyString (org.mockito.Matchers.anyString)1