Skip to content

Commit

Permalink
chore: close response body
Browse files Browse the repository at this point in the history
  • Loading branch information
Dorien Grönwald committed Jan 26, 2025
1 parent a61da3b commit 6221e70
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/server/http/middleware/pagination_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func TestPaginationMiddleware(t *testing.T) {
req := httptest.NewRequest("GET", "/pagination-test", nil)
resp, err := app.Test(req)
assert.NoError(t, err)
defer resp.Body.Close()

var result map[string]interface{}
assert.NoError(t, json.NewDecoder(resp.Body).Decode(&result))
Expand All @@ -37,6 +38,7 @@ func TestPaginationMiddleware(t *testing.T) {
req := httptest.NewRequest("GET", "/pagination-test?page=2&limit=10", nil)
resp, err := app.Test(req)
assert.NoError(t, err)
defer resp.Body.Close()

var result map[string]interface{}
assert.NoError(t, json.NewDecoder(resp.Body).Decode(&result))
Expand All @@ -49,6 +51,7 @@ func TestPaginationMiddleware(t *testing.T) {
req := httptest.NewRequest("GET", "/pagination-test?page=abc&limit=10", nil)
resp, err := app.Test(req)
assert.NoError(t, err)
defer resp.Body.Close()

assert.Equal(t, 400, resp.StatusCode)
})
Expand All @@ -57,6 +60,7 @@ func TestPaginationMiddleware(t *testing.T) {
req := httptest.NewRequest("GET", "/pagination-test?page=0&limit=10", nil)
resp, err := app.Test(req)
assert.NoError(t, err)
defer resp.Body.Close()

assert.Equal(t, 400, resp.StatusCode)
})
Expand All @@ -65,6 +69,7 @@ func TestPaginationMiddleware(t *testing.T) {
req := httptest.NewRequest("GET", "/pagination-test?page=2&limit=xyz", nil)
resp, err := app.Test(req)
assert.NoError(t, err)
defer resp.Body.Close()

assert.Equal(t, 400, resp.StatusCode)
})
Expand All @@ -73,6 +78,7 @@ func TestPaginationMiddleware(t *testing.T) {
req := httptest.NewRequest("GET", "/pagination-test?page=2&limit=-10", nil)
resp, err := app.Test(req)
assert.NoError(t, err)
defer resp.Body.Close()

assert.Equal(t, 400, resp.StatusCode)
})
Expand All @@ -81,6 +87,7 @@ func TestPaginationMiddleware(t *testing.T) {
req := httptest.NewRequest("GET", "/pagination-test?page=2&limit=0", nil)
resp, err := app.Test(req)
assert.NoError(t, err)
defer resp.Body.Close()

assert.Equal(t, 400, resp.StatusCode)
})
Expand Down

0 comments on commit 6221e70

Please sign in to comment.