Skip to content

Commit 61869c8

Browse files
author
AE
committed
Adds tests for inspect command when size is used.
1 parent 4fc98a0 commit 61869c8

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/test/java/com/github/dockerjava/core/command/InspectContainerCmdImplTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,23 @@ public void inspectContainer() throws DockerException {
6363

6464
}
6565

66+
@Test()
67+
public void inspectContainerWithSize() throws DockerException {
68+
69+
String containerName = "generated_" + new SecureRandom().nextInt();
70+
71+
CreateContainerResponse container = dockerClient.createContainerCmd("busybox").withCmd("top")
72+
.withName(containerName).exec();
73+
LOG.info("Created container {}", container.toString());
74+
assertThat(container.getId(), not(isEmptyString()));
75+
76+
InspectContainerResponse containerInfo = dockerClient.inspectContainerCmd(container.getId())
77+
.withSize(true)
78+
.exec();
79+
assertNotNull(containerInfo.getSizeRootFs());
80+
assertEquals(containerInfo.getId(), container.getId());
81+
}
82+
6683
@Test(expectedExceptions = NotFoundException.class)
6784
public void inspectNonExistingContainer() throws DockerException {
6885
dockerClient.inspectContainerCmd("non-existing").exec();

src/test/java/com/github/dockerjava/netty/exec/InspectContainerCmdExecTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,21 @@ public void inspectContainer() throws DockerException {
6363

6464
}
6565

66+
@Test()
67+
public void inspectContainerWithSize() throws DockerException {
68+
69+
String containerName = "generated_" + new SecureRandom().nextInt();
70+
71+
CreateContainerResponse container = dockerClient.createContainerCmd("busybox").withCmd("top")
72+
.withName(containerName).exec();
73+
LOG.info("Created container {}", container.toString());
74+
assertThat(container.getId(), not(isEmptyString()));
75+
76+
InspectContainerResponse containerInfo = dockerClient.inspectContainerCmd(container.getId()).exec();
77+
assertEquals(containerInfo.getId(), container.getId());
78+
assertNotNull(containerInfo.getSizeRootFs());
79+
}
80+
6681
@Test(expectedExceptions = NotFoundException.class)
6782
public void inspectNonExistingContainer() throws DockerException {
6883
dockerClient.inspectContainerCmd("non-existing").exec();

0 commit comments

Comments
 (0)