mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
add test and move one from rm to rmi
Signed-off-by: Victor Vieux <vieux@docker.com>
This commit is contained in:
parent
06b74875b6
commit
c68e6b15a5
2 changed files with 27 additions and 20 deletions
|
@ -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) {
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue