From 1d18070b84dd39d51a6a2c78176b0a18cd612a7e Mon Sep 17 00:00:00 2001 From: Jaycean Date: Mon, 1 Mar 2021 18:04:11 +0800 Subject: [PATCH] Add respbody error assertion and defer resp.Body.Close () --- .../upstream/upstream_chash_query_string_arg_xxx_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api/test/e2enew/upstream/upstream_chash_query_string_arg_xxx_test.go b/api/test/e2enew/upstream/upstream_chash_query_string_arg_xxx_test.go index 18f36208d1..8bd8a3d00e 100644 --- a/api/test/e2enew/upstream/upstream_chash_query_string_arg_xxx_test.go +++ b/api/test/e2enew/upstream/upstream_chash_query_string_arg_xxx_test.go @@ -92,14 +92,15 @@ var _ = ginkgo.Describe("Upstream chash query string", func() { assert.Nil(t, err) resp, err := http.DefaultClient.Do(req) assert.Nil(t, err) + defer resp.Body.Close() respBody, err := ioutil.ReadAll(resp.Body) + assert.Nil(t, err) body := string(respBody) if _, ok := res[body]; !ok { res[body] = 1 } else { res[body]++ } - resp.Body.Close() } var counts []int for _, value := range res { @@ -179,14 +180,15 @@ var _ = ginkgo.Describe("Upstream chash query string", func() { assert.Nil(t, err) resp, err := http.DefaultClient.Do(req) assert.Nil(t, err) + defer resp.Body.Close() respBody, err := ioutil.ReadAll(resp.Body) + assert.Nil(t, err) body := string(respBody) if _, ok := res[body]; !ok { res[body] = 1 } else { res[body]++ } - resp.Body.Close() } var counts []int for _, value := range res {