summaryrefslogtreecommitdiff
path: root/integration-cli/docker_api_attach_test.go
diff options
context:
space:
mode:
authorAntonio Murdaca <me@runcom.ninja>2015-04-27 13:56:55 +0200
committerAntonio Murdaca <me@runcom.ninja>2015-04-27 13:56:55 +0200
commitc7b2632dc8550c8aa80ebd8b229809ac37fa53e1 (patch)
tree5e3f8c206ea6ee0cf5bcb98f355bbae7c72059be /integration-cli/docker_api_attach_test.go
parent6cba3109c2a9c0c20d2541605a9aa7873225a224 (diff)
downloaddocker-c7b2632dc8550c8aa80ebd8b229809ac37fa53e1.tar.gz
Remove c.Fatal from goroutine in TestGetContainersAttachWebsocket
Signed-off-by: Antonio Murdaca <me@runcom.ninja>
Diffstat (limited to 'integration-cli/docker_api_attach_test.go')
-rw-r--r--integration-cli/docker_api_attach_test.go36
1 files changed, 25 insertions, 11 deletions
diff --git a/integration-cli/docker_api_attach_test.go b/integration-cli/docker_api_attach_test.go
index ce7f85d306..c784d5c369 100644
--- a/integration-cli/docker_api_attach_test.go
+++ b/integration-cli/docker_api_attach_test.go
@@ -40,24 +40,38 @@ func (s *DockerSuite) TestGetContainersAttachWebsocket(c *check.C) {
expected := []byte("hello")
actual := make([]byte, len(expected))
- outChan := make(chan string)
+
+ outChan := make(chan error)
go func() {
- if _, err := ws.Read(actual); err != nil {
- c.Fatal(err)
- }
- outChan <- "done"
+ _, err := ws.Read(actual)
+ outChan <- err
+ close(outChan)
}()
- inChan := make(chan string)
+ inChan := make(chan error)
go func() {
- if _, err := ws.Write(expected); err != nil {
+ _, err := ws.Write(expected)
+ inChan <- err
+ close(inChan)
+ }()
+
+ select {
+ case err := <-inChan:
+ if err != nil {
c.Fatal(err)
}
- inChan <- "done"
- }()
+ case <-time.After(5 * time.Second):
+ c.Fatal("Timeout writing to ws")
+ }
- <-inChan
- <-outChan
+ select {
+ case err := <-outChan:
+ if err != nil {
+ c.Fatal(err)
+ }
+ case <-time.After(5 * time.Second):
+ c.Fatal("Timeout reading from ws")
+ }
if !bytes.Equal(expected, actual) {
c.Fatal("Expected output on websocket to match input")