Remove c.Fatal from goroutine in TestGetContainersAttachWebsocket

Signed-off-by: Antonio Murdaca <me@runcom.ninja>
This commit is contained in:
Antonio Murdaca 2015-04-27 13:56:55 +02:00
parent 6cba3109c2
commit c7b2632dc8
1 changed files with 26 additions and 12 deletions

View File

@ -40,24 +40,38 @@ func (s *DockerSuite) TestGetContainersAttachWebsocket(c *check.C) {
expected := []byte("hello") expected := []byte("hello")
actual := make([]byte, len(expected)) actual := make([]byte, len(expected))
outChan := make(chan string)
outChan := make(chan error)
go func() { go func() {
if _, err := ws.Read(actual); err != nil { _, err := ws.Read(actual)
c.Fatal(err) outChan <- err
} close(outChan)
outChan <- "done"
}() }()
inChan := make(chan string) inChan := make(chan error)
go func() { go func() {
if _, err := ws.Write(expected); err != nil { _, err := ws.Write(expected)
c.Fatal(err) inChan <- err
} close(inChan)
inChan <- "done"
}() }()
<-inChan select {
<-outChan case err := <-inChan:
if err != nil {
c.Fatal(err)
}
case <-time.After(5 * time.Second):
c.Fatal("Timeout writing to ws")
}
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) { if !bytes.Equal(expected, actual) {
c.Fatal("Expected output on websocket to match input") c.Fatal("Expected output on websocket to match input")