MCPcopy Index your code
hub / github.com/labstack/echo / TestBodyLimit

Function TestBodyLimit

middleware/body_limit_test.go:171–191  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

169}
170
171func TestBodyLimit(t *testing.T) {
172 e := echo.New()
173 hw := []byte("Hello, World!")
174 req := httptest.NewRequest(http.MethodPost, "/", bytes.NewReader(hw))
175 rec := httptest.NewRecorder()
176 c := e.NewContext(req, rec)
177 h := func(c *echo.Context) error {
178 body, err := io.ReadAll(c.Request().Body)
179 if err != nil {
180 return err
181 }
182 return c.String(http.StatusOK, string(body))
183 }
184
185 mw := BodyLimit(2 * MB)
186
187 err := mw(h)(c)
188 assert.NoError(t, err)
189 assert.Equal(t, http.StatusOK, rec.Code)
190 assert.Equal(t, hw, rec.Body.Bytes())
191}

Callers

nothing calls this directly

Calls 4

RequestMethod · 0.95
StringMethod · 0.95
BodyLimitFunction · 0.85
NewContextMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…