fix defer leak (#1477)

pull/1488/head
letian 3 years ago committed by GitHub
parent 2ce8f22fac
commit 894fc1a058
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      transport/http/server_test.go

@ -96,8 +96,8 @@ func testClient(t *testing.T, srv *Server) {
defer client.Close()
for _, test := range tests {
var res testData
url := fmt.Sprintf(e.String() + test.path)
req, err := http.NewRequest(test.method, url, nil)
reqURL := fmt.Sprintf(e.String() + test.path)
req, err := http.NewRequest(test.method, reqURL, nil)
if err != nil {
t.Fatal(err)
}
@ -110,11 +110,12 @@ func testClient(t *testing.T, srv *Server) {
if err != nil {
t.Fatal(err)
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
_ = resp.Body.Close()
t.Fatalf("http status got %d", resp.StatusCode)
}
content, err := ioutil.ReadAll(resp.Body)
_ = resp.Body.Close()
if err != nil {
t.Fatalf("read resp error %v", err)
}

Loading…
Cancel
Save