Search in sources :

Example 1 with VolumeList

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

the class DefaultDockerClientTest method testListVolumes.

@Test
public void testListVolumes() throws Exception {
    requireDockerApiVersionAtLeast("1.21", "volumes");
    final Volume volume = sut.createVolume();
    final String volumeName = volume.name();
    final String volumeDriver = volume.driver();
    final VolumeList volumeList = sut.listVolumes();
    if (volumeList.warnings() != null && volumeList.warnings().isEmpty()) {
        for (final String warning : volumeList.warnings()) {
            log.warn(warning);
        }
    }
    assertThat(volume, isIn(volumeList.volumes()));
    final VolumeList volumeListWithDangling = sut.listVolumes(dangling());
    if (volumeListWithDangling.warnings() != null && !volumeListWithDangling.warnings().isEmpty()) {
        for (final String warning : volumeListWithDangling.warnings()) {
            log.warn(warning);
        }
    }
    assertThat(volume, isIn(volumeListWithDangling.volumes()));
    if (dockerApiVersionAtLeast("1.24")) {
        final VolumeList volumeListByName = sut.listVolumes(name(volumeName));
        if (volumeListByName.warnings() != null && !volumeListByName.warnings().isEmpty()) {
            for (final String warning : volumeListByName.warnings()) {
                log.warn(warning);
            }
        }
        assertThat(volume, isIn(volumeListByName.volumes()));
        final VolumeList volumeListByDriver = sut.listVolumes(driver(volumeDriver));
        if (volumeListByDriver.warnings() != null && !volumeListByDriver.warnings().isEmpty()) {
            for (final String warning : volumeListByDriver.warnings()) {
                log.warn(warning);
            }
        }
        assertThat(volume, isIn(volumeListByDriver.volumes()));
    }
    if (dockerApiVersionAtLeast("1.24")) {
        assertEquals("local", volume.scope());
        // I don't know what is in the status object - JF
        assertThat(volume.status(), is(anything()));
    }
    sut.removeVolume(volume);
}
Also used : Volume(com.spotify.docker.client.messages.Volume) Long.toHexString(java.lang.Long.toHexString) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) Matchers.containsString(org.hamcrest.Matchers.containsString) VolumeList(com.spotify.docker.client.messages.VolumeList) Test(org.junit.Test)

Aggregations

Volume (com.spotify.docker.client.messages.Volume)1 VolumeList (com.spotify.docker.client.messages.VolumeList)1 Long.toHexString (java.lang.Long.toHexString)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 Matchers.isEmptyOrNullString (org.hamcrest.Matchers.isEmptyOrNullString)1 Test (org.junit.Test)1