Browse code

add test and move one from rm to rmi

Signed-off-by: Victor Vieux <vieux@docker.com>

Victor Vieux authored on 2014/10/03 08:39:39
Showing 2 changed files
... ...
@@ -110,28 +110,12 @@ func TestRmContainerOrphaning(t *testing.T) {
110 110
 	logDone("rm - container orphaning")
111 111
 }
112 112
 
113
-func TestRmTagWithExistingContainers(t *testing.T) {
114
-	container := "test-delete-tag"
115
-	newtag := "busybox:newtag"
116
-	bb := "busybox:latest"
117
-	if out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "tag", bb, newtag)); err != nil {
118
-		t.Fatalf("Could not tag busybox: %v: %s", err, out)
113
+func TestRmInvalidContainer(t *testing.T) {
114
+	if _, _, err := runCommandWithOutput(exec.Command(dockerBinary, "rm", "unknown")); err == nil {
115
+		t.Fatal("Expected error on rm unknown container, got none")
119 116
 	}
120
-	if out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "run", "--name", container, bb, "/bin/true")); err != nil {
121
-		t.Fatalf("Could not run busybox: %v: %s", err, out)
122
-	}
123
-	out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "rmi", newtag))
124
-	if err != nil {
125
-		t.Fatalf("Could not remove tag %s: %v: %s", newtag, err, out)
126
-	}
127
-	if d := strings.Count(out, "Untagged: "); d != 1 {
128
-		t.Fatalf("Expected 1 untagged entry got %d: %q", d, out)
129
-	}
130
-
131
-	deleteAllContainers()
132
-
133
-	logDone("rm - delete tag with existing containers")
134 117
 
118
+	logDone("rm - delete unknown container")
135 119
 }
136 120
 
137 121
 func createRunningContainer(t *testing.T, name string) {
... ...
@@ -75,3 +75,26 @@ func TestRmiTag(t *testing.T) {
75 75
 	}
76 76
 	logDone("tag,rmi- tagging the same images multiple times then removing tags")
77 77
 }
78
+
79
+func TestRmiTagWithExistingContainers(t *testing.T) {
80
+	container := "test-delete-tag"
81
+	newtag := "busybox:newtag"
82
+	bb := "busybox:latest"
83
+	if out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "tag", bb, newtag)); err != nil {
84
+		t.Fatalf("Could not tag busybox: %v: %s", err, out)
85
+	}
86
+	if out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "run", "--name", container, bb, "/bin/true")); err != nil {
87
+		t.Fatalf("Could not run busybox: %v: %s", err, out)
88
+	}
89
+	out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "rmi", newtag))
90
+	if err != nil {
91
+		t.Fatalf("Could not remove tag %s: %v: %s", newtag, err, out)
92
+	}
93
+	if d := strings.Count(out, "Untagged: "); d != 1 {
94
+		t.Fatalf("Expected 1 untagged entry got %d: %q", d, out)
95
+	}
96
+
97
+	deleteAllContainers()
98
+
99
+	logDone("rmi - delete tag with existing containers")
100
+}