forked from cerc-io/plugeth
metrics/librato: ensure resp.body closed (#26969)
This change ensures that we call Close on a http response body, in various places in the source code (mostly tests)
This commit is contained in:
@@ -156,6 +156,7 @@ func TestGraphQLBlockSerialization(t *testing.T) {
|
||||
t.Fatalf("could not post: %v", err)
|
||||
}
|
||||
bodyBytes, err := io.ReadAll(resp.Body)
|
||||
resp.Body.Close()
|
||||
if err != nil {
|
||||
t.Fatalf("could not read from response body: %v", err)
|
||||
}
|
||||
@@ -239,6 +240,7 @@ func TestGraphQLBlockSerializationEIP2718(t *testing.T) {
|
||||
t.Fatalf("could not post: %v", err)
|
||||
}
|
||||
bodyBytes, err := io.ReadAll(resp.Body)
|
||||
resp.Body.Close()
|
||||
if err != nil {
|
||||
t.Fatalf("could not read from response body: %v", err)
|
||||
}
|
||||
@@ -263,6 +265,7 @@ func TestGraphQLHTTPOnSamePort_GQLRequest_Unsuccessful(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("could not post: %v", err)
|
||||
}
|
||||
resp.Body.Close()
|
||||
// make sure the request is not handled successfully
|
||||
assert.Equal(t, http.StatusNotFound, resp.StatusCode)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user