From c68e6b15a5d128eee1637c55471907d90cb828d2 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Thu, 2 Oct 2014 23:39:39 +0000 Subject: [PATCH 1/2] add test and move one from rm to rmi Signed-off-by: Victor Vieux --- integration-cli/docker_cli_rm_test.go | 24 ++++-------------------- integration-cli/docker_cli_rmi_test.go | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/integration-cli/docker_cli_rm_test.go b/integration-cli/docker_cli_rm_test.go index 9aab6bc6e3..25b1435a7c 100644 --- a/integration-cli/docker_cli_rm_test.go +++ b/integration-cli/docker_cli_rm_test.go @@ -110,28 +110,12 @@ func TestRmContainerOrphaning(t *testing.T) { logDone("rm - container orphaning") } -func TestRmTagWithExistingContainers(t *testing.T) { - container := "test-delete-tag" - newtag := "busybox:newtag" - bb := "busybox:latest" - if out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "tag", bb, newtag)); err != nil { - t.Fatalf("Could not tag busybox: %v: %s", err, out) - } - if out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "run", "--name", container, bb, "/bin/true")); err != nil { - t.Fatalf("Could not run busybox: %v: %s", err, out) - } - out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "rmi", newtag)) - if err != nil { - t.Fatalf("Could not remove tag %s: %v: %s", newtag, err, out) - } - if d := strings.Count(out, "Untagged: "); d != 1 { - t.Fatalf("Expected 1 untagged entry got %d: %q", d, out) +func TestRmInvalidContainer(t *testing.T) { + if _, _, err := runCommandWithOutput(exec.Command(dockerBinary, "rm", "unknown")); err == nil { + t.Fatal("Expected error on rm unknown container, got none") } - deleteAllContainers() - - logDone("rm - delete tag with existing containers") - + logDone("rm - delete unknown container") } func createRunningContainer(t *testing.T, name string) { diff --git a/integration-cli/docker_cli_rmi_test.go b/integration-cli/docker_cli_rmi_test.go index 1b30b9541b..4fb150bab8 100644 --- a/integration-cli/docker_cli_rmi_test.go +++ b/integration-cli/docker_cli_rmi_test.go @@ -75,3 +75,26 @@ func TestRmiTag(t *testing.T) { } logDone("tag,rmi- tagging the same images multiple times then removing tags") } + +func TestRmiTagWithExistingContainers(t *testing.T) { + container := "test-delete-tag" + newtag := "busybox:newtag" + bb := "busybox:latest" + if out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "tag", bb, newtag)); err != nil { + t.Fatalf("Could not tag busybox: %v: %s", err, out) + } + if out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "run", "--name", container, bb, "/bin/true")); err != nil { + t.Fatalf("Could not run busybox: %v: %s", err, out) + } + out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "rmi", newtag)) + if err != nil { + t.Fatalf("Could not remove tag %s: %v: %s", newtag, err, out) + } + if d := strings.Count(out, "Untagged: "); d != 1 { + t.Fatalf("Expected 1 untagged entry got %d: %q", d, out) + } + + deleteAllContainers() + + logDone("rmi - delete tag with existing containers") +} From 3e473c08b479e3ad783b31ad564f46ab87c8f034 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Mon, 6 Oct 2014 18:18:25 +0000 Subject: [PATCH 2/2] update test Signed-off-by: Victor Vieux --- integration-cli/docker_cli_rm_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/integration-cli/docker_cli_rm_test.go b/integration-cli/docker_cli_rm_test.go index 25b1435a7c..6c8dc38089 100644 --- a/integration-cli/docker_cli_rm_test.go +++ b/integration-cli/docker_cli_rm_test.go @@ -111,8 +111,10 @@ func TestRmContainerOrphaning(t *testing.T) { } func TestRmInvalidContainer(t *testing.T) { - if _, _, err := runCommandWithOutput(exec.Command(dockerBinary, "rm", "unknown")); err == nil { + if out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "rm", "unknown")); err == nil { t.Fatal("Expected error on rm unknown container, got none") + } else if !strings.Contains(out, "failed to remove one or more containers") { + t.Fatal("Expected output to contain 'failed to remove one or more containers', got %q", out) } logDone("rm - delete unknown container")