1
0
mirror of https://github.com/golang/go synced 2024-11-27 01:21:18 -07:00

net/http: make use of testing.Errorf instead of testing.Fatalf in non-test function goroutines

See testing.FailNow for further information.
Also avoid nil pointer derefernce in TestTransportMaxPerHostIdleConns.

LGTM=dave
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/76470043
This commit is contained in:
Mikio Hara 2014-03-18 21:12:00 +09:00
parent 41818f8fcc
commit d7039b71a9

View File

@ -349,10 +349,11 @@ func TestTransportMaxPerHostIdleConns(t *testing.T) {
resp, err := c.Get(ts.URL)
if err != nil {
t.Error(err)
return
}
_, err = ioutil.ReadAll(resp.Body)
if err != nil {
t.Fatalf("ReadAll: %v", err)
if _, err := ioutil.ReadAll(resp.Body); err != nil {
t.Errorf("ReadAll: %v", err)
return
}
donech <- true
}
@ -1808,15 +1809,18 @@ func TestTransportTLSHandshakeTimeout(t *testing.T) {
cl := &Client{Transport: tr}
_, err := cl.Get("https://dummy.tld/")
if err == nil {
t.Fatal("expected error")
t.Error("expected error")
return
}
ue, ok := err.(*url.Error)
if !ok {
t.Fatalf("expected url.Error; got %#v", err)
t.Errorf("expected url.Error; got %#v", err)
return
}
ne, ok := ue.Err.(net.Error)
if !ok {
t.Fatalf("expected net.Error; got %#v", err)
t.Errorf("expected net.Error; got %#v", err)
return
}
if !ne.Timeout() {
t.Error("expected timeout error; got %v", err)