Skip to content

Commit

Permalink
Add respbody error assertion and defer resp.Body.Close ()
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaycean committed Mar 1, 2021
1 parent 04c4450 commit 1d18070
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 1d18070

Please sign in to comment.