diff --git a/proxy_test.go b/proxy_test.go index 42b668bd08c..c9604be6235 100644 --- a/proxy_test.go +++ b/proxy_test.go @@ -119,16 +119,16 @@ func testHTTPConnect(t *testing.T, proxyURLModify func(*url.URL) *url.URL, proxy msg := []byte{4, 3, 5, 2} recvBuf := make([]byte, len(msg)) - done := make(chan struct{}) + done := make(chan error) go func() { in, err := blis.Accept() if err != nil { - t.Errorf("failed to accept: %v", err) + done <- err return } defer in.Close() in.Read(recvBuf) - close(done) + done <- nil }() // Overwrite the function in the test and restore them in defer. @@ -154,7 +154,9 @@ func testHTTPConnect(t *testing.T, proxyURLModify func(*url.URL) *url.URL, proxy // Send msg on the connection. c.Write(msg) - <-done + if err := <-done; err != nil { + t.Fatalf("failed to accept: %v", err) + } // Check received msg. if string(recvBuf) != string(msg) {