MCPcopy
hub / github.com/gofiber/fiber / Test_App_BodyLimit_Zero

Function Test_App_BodyLimit_Zero

app_test.go:480–499  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

478}
479
480func Test_App_BodyLimit_Zero(t *testing.T) {
481 t.Parallel()
482
483 app := New(Config{BodyLimit: 0})
484
485 app.Post("/", func(c Ctx) error {
486 return c.SendStatus(StatusOK)
487 })
488
489 largeBody := bytes.Repeat([]byte{'a'}, DefaultBodyLimit+1)
490 req := httptest.NewRequest(MethodPost, "/", bytes.NewReader(largeBody))
491 _, err := app.Test(req)
492 require.ErrorIs(t, err, fasthttp.ErrBodyTooLarge)
493
494 smallBody := bytes.Repeat([]byte{'a'}, DefaultBodyLimit-1)
495 req = httptest.NewRequest(MethodPost, "/", bytes.NewReader(smallBody))
496 resp, err := app.Test(req)
497 require.NoError(t, err)
498 require.Equal(t, StatusOK, resp.StatusCode)
499}
500
501func Test_App_BodyLimit_LargerThanDefault(t *testing.T) {
502 t.Parallel()

Callers

nothing calls this directly

Calls 4

TestMethod · 0.80
NewFunction · 0.70
PostMethod · 0.65
SendStatusMethod · 0.65

Tested by

no test coverage detected