Skip to content

Commit

Permalink
Add a 'docker create' + 'docker rm' testcase
Browse files Browse the repository at this point in the history
Per @thaJeztah's comment here: moby#13367 (comment)
I couldn't find an existing test that covered this.

Signed-off-by: Doug Davis <[email protected]>
  • Loading branch information
Doug Davis committed May 21, 2015
1 parent ef0a145 commit 012e588
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions integration-cli/docker_cli_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,36 @@ func (s *DockerSuite) TestCreateHostnameWithNumber(c *check.C) {
c.Fatalf("hostname not set, expected `web.0`, got: %s", out)
}
}

func (s *DockerSuite) TestCreateRM(c *check.C) {
// Test to make sure we can 'rm' a new container that is in
// "Created" state, and has ever been run. Test "rm -f" too.

// create a container
createCmd := exec.Command(dockerBinary, "create", "busybox")
out, _, err := runCommandWithOutput(createCmd)
if err != nil {
c.Fatalf("Failed to create container:%s\n%s", out, err)
}
cID := strings.TrimSpace(out)

rmCmd := exec.Command(dockerBinary, "rm", cID)
out, _, err = runCommandWithOutput(rmCmd)
if err != nil {
c.Fatalf("Failed to rm container:%s\n%s", out, err)
}

// Now do it again so we can "rm -f" this time
createCmd = exec.Command(dockerBinary, "create", "busybox")
out, _, err = runCommandWithOutput(createCmd)
if err != nil {
c.Fatalf("Failed to create 2nd container:%s\n%s", out, err)
}

cID = strings.TrimSpace(out)
rmCmd = exec.Command(dockerBinary, "rm", "-f", cID)
out, _, err = runCommandWithOutput(rmCmd)
if err != nil {
c.Fatalf("Failed to rm -f container:%s\n%s", out, err)
}
}

0 comments on commit 012e588

Please sign in to comment.