Search in sources :

Example 1 with TagParams

use of org.eclipse.che.plugin.docker.client.params.TagParams 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)

Example 2 with TagParams

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

the class DockerConnectorTest method shouldBeAbleToTagImage.

@Test
public void shouldBeAbleToTagImage() throws IOException {
    TagParams tagParams = TagParams.create(IMAGE, REPOSITORY);
    dockerConnector.tag(tagParams);
    verify(dockerConnectionFactory).openConnection(any(URI.class));
    verify(dockerConnection).method(REQUEST_METHOD_POST);
    verify(dockerConnection).path("/images/" + tagParams.getImage() + "/tag");
    verify(dockerConnection).query("repo", tagParams.getRepository());
    verify(dockerConnection).request();
    verify(dockerResponse).getStatus();
}
Also used : TagParams(org.eclipse.che.plugin.docker.client.params.TagParams) URI(java.net.URI) Test(org.testng.annotations.Test)

Example 3 with TagParams

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

the class DockerConnectorTest method shouldThrowDockerExceptionWhileTaggingImageIfResponseCodeIsNotSuccess.

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

Aggregations

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