mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Make sure the container is running before testing against it (TestAttachDetach)
This commit is contained in:
parent
77c94175bd
commit
e535f544c7
1 changed files with 11 additions and 2 deletions
|
@ -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])
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue