go 1.4 doesn't like closed connection, check we closed the listener

This commit is contained in:
Asim 2016-03-14 18:20:38 +00:00
parent 77177508ce
commit fe1fde8c59

View File

@ -52,6 +52,8 @@ func TestHTTPTransportCommunication(t *testing.T) {
defer l.Close()
fn := func(sock transport.Socket) {
defer sock.Close()
for {
var m transport.Message
if err := sock.Recv(&m); err != nil {
@ -66,10 +68,16 @@ func TestHTTPTransportCommunication(t *testing.T) {
}
}
done := make(chan bool)
go func() {
if err := l.Accept(fn); err != nil {
select {
case <-done:
default:
t.Errorf("Unexpected accept err: %v", err)
}
}
}()
c, err := tr.Dial(l.Addr())
@ -98,4 +106,6 @@ func TestHTTPTransportCommunication(t *testing.T) {
if string(rm.Body) != string(m.Body) {
t.Errorf("Expected %v, got %v", m.Body, rm.Body)
}
close(done)
}