From e23dd7927d675777f3fba54db39ced0cb1e02a65 Mon Sep 17 00:00:00 2001 From: Kit Patella Date: Mon, 30 Sep 2024 11:40:29 -0700 Subject: [PATCH] chore: ensure we don't try to close a nil response body Signed-off-by: Kit Patella --- src/test/e2e/21_connect_creds_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/e2e/21_connect_creds_test.go b/src/test/e2e/21_connect_creds_test.go index 2be7f552a2..c3d174ae65 100644 --- a/src/test/e2e/21_connect_creds_test.go +++ b/src/test/e2e/21_connect_creds_test.go @@ -71,12 +71,12 @@ func TestMetrics(t *testing.T) { client := &http.Client{Transport: tr} httpsEndpoint := strings.ReplaceAll(tunnel.HTTPEndpoint(), "http", "https") resp, err := client.Get(httpsEndpoint + "/metrics") - defer func() { - require.NoError(t, resp.Body.Close()) - }() if err != nil { t.Fatal(err) } + defer func() { + require.NoError(t, resp.Body.Close()) + }() // Read the response body body, err := io.ReadAll(resp.Body)