From c45beabcd54090bcb31eaa7a5af5878262b7b0e5 Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Tue, 23 Apr 2013 11:22:30 -0700 Subject: [PATCH] Improve TestMultipleAttachRestart to avoid unnecessary warning --- container_test.go | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/container_test.go b/container_test.go index fef5331e3a..81ae883c3a 100644 --- a/container_test.go +++ b/container_test.go @@ -116,8 +116,8 @@ func TestMultipleAttachRestart(t *testing.T) { if err := container.Start(); err != nil { t.Fatal(err) } - timeout := make(chan bool) - go func() { + + setTimeout(t, "Timeout reading from the process", 3*time.Second, func() { l1, err = bufio.NewReader(stdout1).ReadString('\n') if err != nil { t.Fatal(err) @@ -139,15 +139,8 @@ func TestMultipleAttachRestart(t *testing.T) { if strings.Trim(l3, " \r\n") != "hello" { t.Fatalf("Unexpected output. Expected [%s], received [%s]", "hello", l3) } - timeout <- false - }() - go func() { - time.Sleep(3 * time.Second) - timeout <- true - }() - if <-timeout { - t.Fatalf("Timeout reading from the process") - } + }) + container.Wait() } func TestDiff(t *testing.T) {