Make sure the container is running before testing against it (TestAttachDetach)

This commit is contained in:
Guillaume J. Charmes 2013-11-29 07:39:51 -08:00
parent 77c94175bd
commit e535f544c7
No known key found for this signature in database
GPG Key ID: B33E4642CB6E3FF3
1 changed files with 11 additions and 2 deletions

View File

@ -481,6 +481,17 @@ func TestAttachDetach(t *testing.T) {
var container *docker.Container
setTimeout(t, "Waiting for the container to be started timed out", 10*time.Second, func() {
for {
l := globalRuntime.List()
if len(l) == 1 && l[0].State.IsRunning() {
container = l[0]
break
}
time.Sleep(10 * time.Millisecond)
}
})
setTimeout(t, "Reading container's id timed out", 10*time.Second, func() {
buf := make([]byte, 1024)
n, err := stdout.Read(buf)
@ -488,8 +499,6 @@ func TestAttachDetach(t *testing.T) {
t.Fatal(err)
}
container = globalRuntime.List()[0]
if strings.Trim(string(buf[:n]), " \r\n") != container.ID {
t.Fatalf("Wrong ID received. Expect %s, received %s", container.ID, buf[:n])
}