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

Function Test_App_BodyLimit_Negative

app_test.go:456–478  ·  app_test.go::Test_App_BodyLimit_Negative
(t *testing.T)

Source from the content-addressed store, hash-verified

454}
455
456func Test_App_BodyLimit_Negative(t *testing.T) {
457 t.Parallel()
458
459 limits := []int{-1, -512}
460 for _, limit := range limits {
461 app := New(Config{BodyLimit: limit})
462
463 app.Post("/", func(c Ctx) error {
464 return c.SendStatus(StatusOK)
465 })
466
467 largeBody := bytes.Repeat([]byte{'a'}, DefaultBodyLimit+1)
468 req := httptest.NewRequest(MethodPost, "/", bytes.NewReader(largeBody))
469 _, err := app.Test(req)
470 require.ErrorIs(t, err, fasthttp.ErrBodyTooLarge)
471
472 smallBody := bytes.Repeat([]byte{'a'}, DefaultBodyLimit-1)
473 req = httptest.NewRequest(MethodPost, "/", bytes.NewReader(smallBody))
474 resp, err := app.Test(req)
475 require.NoError(t, err)
476 require.Equal(t, StatusOK, resp.StatusCode)
477 }
478}
479
480func Test_App_BodyLimit_Zero(t *testing.T) {
481 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