Search in sources :

Example 1 with RemovedImage

use of com.spotify.docker.client.messages.RemovedImage in project docker-client by spotify.

the class DefaultDockerClientTest method testTag.

@Test
public void testTag() throws Exception {
    sut.pull(BUSYBOX_LATEST);
    // Tag image
    final String newImageName = "test-repo:testTag";
    sut.tag(BUSYBOX, newImageName);
    // Verify tag was successful by trying to remove it.
    final RemovedImage removedImage = getOnlyElement(sut.removeImage(newImageName));
    assertThat(removedImage, equalTo(RemovedImage.create(UNTAGGED, newImageName)));
}
Also used : RemovedImage(com.spotify.docker.client.messages.RemovedImage) Long.toHexString(java.lang.Long.toHexString) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 2 with RemovedImage

use of com.spotify.docker.client.messages.RemovedImage in project docker-client by spotify.

the class DefaultDockerClientTest method testRemoveImage.

@Test
public void testRemoveImage() throws Exception {
    // Don't remove images on CircleCI. Their version of Docker causes failures when pulling an
    // image that shares layers with an image that has been removed. This causes tests after this
    // one to fail.
    assumeFalse(CIRCLECI);
    sut.pull("dxia/cirros:latest");
    sut.pull("dxia/cirros:0.3.0");
    final String imageLatest = "dxia/cirros:latest";
    final String imageVersion = "dxia/cirros:0.3.0";
    final Set<RemovedImage> removedImages = Sets.newHashSet();
    removedImages.addAll(sut.removeImage(imageLatest));
    removedImages.addAll(sut.removeImage(imageVersion));
    assertThat(removedImages, hasItems(RemovedImage.create(UNTAGGED, imageLatest), RemovedImage.create(UNTAGGED, imageVersion)));
    // Try to inspect deleted image and make sure ImageNotFoundException is thrown
    try {
        sut.inspectImage(imageLatest);
        fail("inspectImage should have thrown ImageNotFoundException");
    } catch (ImageNotFoundException e) {
    // we should get exception because we deleted image
    }
}
Also used : RemovedImage(com.spotify.docker.client.messages.RemovedImage) Long.toHexString(java.lang.Long.toHexString) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) Matchers.containsString(org.hamcrest.Matchers.containsString) ImageNotFoundException(com.spotify.docker.client.exceptions.ImageNotFoundException) Test(org.junit.Test)

Example 3 with RemovedImage

use of com.spotify.docker.client.messages.RemovedImage in project docker-client by spotify.

the class DefaultDockerClientTest method testTagForce.

@Test
public void testTagForce() throws Exception {
    sut.pull(BUSYBOX_LATEST);
    sut.pull(BUSYBOX_BUILDROOT_2013_08_1);
    final String name = "test-repo/tag-force:sometag";
    // Assign name to first image
    sut.tag(BUSYBOX_LATEST, name);
    // Force-re-assign tag to another image
    sut.tag(BUSYBOX_BUILDROOT_2013_08_1, name, true);
    // Verify that re-tagging was successful
    final RemovedImage removedImage = getOnlyElement(sut.removeImage(name));
    assertThat(removedImage, is(RemovedImage.create(UNTAGGED, name)));
}
Also used : RemovedImage(com.spotify.docker.client.messages.RemovedImage) Long.toHexString(java.lang.Long.toHexString) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Aggregations

RemovedImage (com.spotify.docker.client.messages.RemovedImage)3 Long.toHexString (java.lang.Long.toHexString)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 Matchers.isEmptyOrNullString (org.hamcrest.Matchers.isEmptyOrNullString)3 Test (org.junit.Test)3 ImageNotFoundException (com.spotify.docker.client.exceptions.ImageNotFoundException)1