mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
Merge pull request #5304 from vieux/convert_rm_tests
convert so rm tests to integration-cli
This commit is contained in:
@@ -25,3 +25,42 @@ func TestRemoveContainerWithRemovedVolume(t *testing.T) {
|
||||
|
||||
logDone("rm - removed volume")
|
||||
}
|
||||
|
||||
func TestRemoveContainerWithVolume(t *testing.T) {
|
||||
cmd := exec.Command(dockerBinary, "run", "--name", "foo", "-v", "/srv", "busybox", "true")
|
||||
if _, err := runCommand(cmd); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
cmd = exec.Command(dockerBinary, "rm", "-v", "foo")
|
||||
if _, err := runCommand(cmd); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
deleteAllContainers()
|
||||
|
||||
logDone("rm - volume")
|
||||
}
|
||||
|
||||
func TestRemoveContainerRunning(t *testing.T) {
|
||||
cmd := exec.Command(dockerBinary, "run", "-d", "--name", "foo", "busybox", "sleep", "300")
|
||||
if _, err := runCommand(cmd); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Test cannot remove running container
|
||||
cmd = exec.Command(dockerBinary, "rm", "foo")
|
||||
if _, err := runCommand(cmd); err == nil {
|
||||
t.Fatalf("Expected error, can't rm a running container")
|
||||
}
|
||||
|
||||
// Remove with -f
|
||||
cmd = exec.Command(dockerBinary, "rm", "-f", "foo")
|
||||
if _, err := runCommand(cmd); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
deleteAllContainers()
|
||||
|
||||
logDone("rm - running container")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user