From: Tom Clegg Date: Thu, 25 May 2023 17:57:58 +0000 (-0400) Subject: 20511: Fix unclosed response body in test. X-Git-Tag: 2.7.0~100^2~2 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/40dcd44173ea6d6cdc53206766875151eac7b0fd 20511: Fix unclosed response body in test. Arvados-DCO-1.1-Signed-off-by: Tom Clegg --- diff --git a/lib/controller/integration_test.go b/lib/controller/integration_test.go index 12fc50089d..0557aa3fdd 100644 --- a/lib/controller/integration_test.go +++ b/lib/controller/integration_test.go @@ -501,6 +501,7 @@ func (s *IntegrationSuite) TestCreateContainerRequestWithFedToken(c *check.C) { req.Header.Set("Authorization", "OAuth2 "+ac2.AuthToken) resp, err = arvados.InsecureHTTPClient.Do(req) c.Assert(err, check.IsNil) + defer resp.Body.Close() err = json.NewDecoder(resp.Body).Decode(&cr) c.Check(err, check.IsNil) c.Check(cr.UUID, check.Matches, "z2222-.*") @@ -538,8 +539,10 @@ func (s *IntegrationSuite) TestCreateContainerRequestWithBadToken(c *check.C) { c.Assert(err, check.IsNil) req.Header.Set("Content-Type", "application/json") resp, err := ac1.Do(req) - c.Assert(err, check.IsNil) - c.Assert(resp.StatusCode, check.Equals, tt.expectedCode) + if c.Check(err, check.IsNil) { + c.Assert(resp.StatusCode, check.Equals, tt.expectedCode) + resp.Body.Close() + } } } @@ -607,9 +610,11 @@ func (s *IntegrationSuite) TestRequestIDHeader(c *check.C) { var jresp httpserver.ErrorResponse err := json.NewDecoder(resp.Body).Decode(&jresp) c.Check(err, check.IsNil) - c.Assert(jresp.Errors, check.HasLen, 1) - c.Check(jresp.Errors[0], check.Matches, `.*\(`+respHdr+`\).*`) + if c.Check(jresp.Errors, check.HasLen, 1) { + c.Check(jresp.Errors[0], check.Matches, `.*\(`+respHdr+`\).*`) + } } + resp.Body.Close() } }