1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/integration-cli/docker_cli_start_test.go
Brian Goff 9ae9d7db57 Fix #7843
When doing `docker start -a` on a container that won't start, terminal
was getting stuck on the attach, even after container removal.

Docker-DCO-1.1-Signed-off-by: Brian Goff <cpuguy83@gmail.com> (github: cpuguy83)
2014-09-26 11:31:02 -04:00

38 lines
1 KiB
Go

package main
import (
"os/exec"
"testing"
"time"
)
// Regression test for https://github.com/docker/docker/issues/7843
func TestStartAttachReturnsOnError(t *testing.T) {
defer deleteAllContainers()
cmd(t, "run", "-d", "--name", "test", "busybox")
cmd(t, "stop", "test")
// Expect this to fail because the above container is stopped, this is what we want
if _, err := runCommand(exec.Command(dockerBinary, "run", "-d", "--name", "test2", "--link", "test:test", "busybox")); err == nil {
t.Fatal("Expected error but got none")
}
ch := make(chan struct{})
go func() {
// Attempt to start attached to the container that won't start
// This should return an error immediately since the container can't be started
if _, err := runCommand(exec.Command(dockerBinary, "start", "-a", "test2")); err == nil {
t.Fatal("Expected error but got none")
}
close(ch)
}()
select {
case <-ch:
case <-time.After(time.Second):
t.Fatalf("Attach did not exit properly")
}
logDone("start - error on start with attach exits")
}