Browse Source

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

Guillaume J. Charmes 11 years ago
parent
commit
e535f544c7
1 changed files with 11 additions and 2 deletions
  1. 11 2
      integration/commands_test.go

+ 11 - 2
integration/commands_test.go

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