Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixes a bug in the InfoCmdTest
If you don't have any of your own containers, the InfoCmd integration
test can fail. This commit makes sure there's at least one container
present.
  • Loading branch information
mfulgo committed Aug 1, 2014
commit 8d572c6e9ce4e2aead81353ca09713e796bd10f7
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@
import com.github.dockerjava.client.DockerException;
import com.github.dockerjava.client.model.Info;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.isEmptyOrNullString;
import static org.hamcrest.Matchers.not;

public class InfoCmdTest extends AbstractDockerClientTest {

@BeforeTest
public void beforeTest() throws DockerException {
super.beforeTest();
}

@AfterTest
public void afterTest() {
super.afterTest();
Expand All @@ -34,10 +38,23 @@ public void beforeMethod(Method method) {
public void afterMethod(ITestResult result) {
super.afterMethod(result);
}

@Test
public void info() throws DockerException {
Info dockerInfo = dockerClient.infoCmd().exec();
// Make sure that there is at least one container for the assertion
// TODO extract this into a shared method
CreateContainerResponse container = dockerClient.createContainerCmd("busybox")
.withName("docker-java-itest-info")
.withCmd("touch", "/test")
.exec();

LOG.info("Created container: {}", container);
assertThat(container.getId(), not(isEmptyOrNullString()));

dockerClient.startContainerCmd(container.getId()).exec();
tmpContainers.add(container.getId());

Info dockerInfo = dockerClient.infoCmd().exec();
LOG.info(dockerInfo.toString());

assertTrue(dockerInfo.toString().contains("containers"));
Expand Down