mirror of
https://github.com/labstack/echo.git
synced 2024-12-24 20:14:31 +02:00
Fix body_limit middleware unit test
This commit is contained in:
parent
63c62bcbe5
commit
572466d928
@ -33,12 +33,13 @@ func TestBodyLimit(t *testing.T) {
|
|||||||
assert.Equal(hw, rec.Body.Bytes())
|
assert.Equal(hw, rec.Body.Bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Based on content read (overlimit)
|
// Based on content length (overlimit)
|
||||||
he := BodyLimit("2B")(h)(c).(*echo.HTTPError)
|
he := BodyLimit("2B")(h)(c).(*echo.HTTPError)
|
||||||
assert.Equal(http.StatusRequestEntityTooLarge, he.Code)
|
assert.Equal(http.StatusRequestEntityTooLarge, he.Code)
|
||||||
|
|
||||||
// Based on content read (within limit)
|
// Based on content read (within limit)
|
||||||
req = httptest.NewRequest(http.MethodPost, "/", bytes.NewReader(hw))
|
req = httptest.NewRequest(http.MethodPost, "/", bytes.NewReader(hw))
|
||||||
|
req.ContentLength = -1
|
||||||
rec = httptest.NewRecorder()
|
rec = httptest.NewRecorder()
|
||||||
c = e.NewContext(req, rec)
|
c = e.NewContext(req, rec)
|
||||||
if assert.NoError(BodyLimit("2M")(h)(c)) {
|
if assert.NoError(BodyLimit("2M")(h)(c)) {
|
||||||
@ -48,6 +49,7 @@ func TestBodyLimit(t *testing.T) {
|
|||||||
|
|
||||||
// Based on content read (overlimit)
|
// Based on content read (overlimit)
|
||||||
req = httptest.NewRequest(http.MethodPost, "/", bytes.NewReader(hw))
|
req = httptest.NewRequest(http.MethodPost, "/", bytes.NewReader(hw))
|
||||||
|
req.ContentLength = -1
|
||||||
rec = httptest.NewRecorder()
|
rec = httptest.NewRecorder()
|
||||||
c = e.NewContext(req, rec)
|
c = e.NewContext(req, rec)
|
||||||
he = BodyLimit("2B")(h)(c).(*echo.HTTPError)
|
he = BodyLimit("2B")(h)(c).(*echo.HTTPError)
|
||||||
|
Loading…
Reference in New Issue
Block a user