Skip to content

Commit 572466d

Browse files
wsx864321aldas
authored andcommitted
Fix body_limit middleware unit test
1 parent 63c62bc commit 572466d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

middleware/body_limit_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@ func TestBodyLimit(t *testing.T) {
3333
assert.Equal(hw, rec.Body.Bytes())
3434
}
3535

36-
// Based on content read (overlimit)
36+
// Based on content length (overlimit)
3737
he := BodyLimit("2B")(h)(c).(*echo.HTTPError)
3838
assert.Equal(http.StatusRequestEntityTooLarge, he.Code)
3939

4040
// Based on content read (within limit)
4141
req = httptest.NewRequest(http.MethodPost, "/", bytes.NewReader(hw))
42+
req.ContentLength = -1
4243
rec = httptest.NewRecorder()
4344
c = e.NewContext(req, rec)
4445
if assert.NoError(BodyLimit("2M")(h)(c)) {
@@ -48,6 +49,7 @@ func TestBodyLimit(t *testing.T) {
4849

4950
// Based on content read (overlimit)
5051
req = httptest.NewRequest(http.MethodPost, "/", bytes.NewReader(hw))
52+
req.ContentLength = -1
5153
rec = httptest.NewRecorder()
5254
c = e.NewContext(req, rec)
5355
he = BodyLimit("2B")(h)(c).(*echo.HTTPError)

0 commit comments

Comments
 (0)