1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #8369 from vieux/add_test_rm

add test and move one from rm to rmi
This commit is contained in:
Victor Vieux 2014-10-06 11:30:12 -07:00
commit 40070609da
2 changed files with 29 additions and 20 deletions

View file

@ -110,28 +110,14 @@ 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 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)
}
deleteAllContainers()
logDone("rm - delete tag with existing containers")
logDone("rm - delete unknown container")
}
func createRunningContainer(t *testing.T, name string) {

View file

@ -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")
}