(t *testing.T)
| 499 | } |
| 500 | |
| 501 | func Test_App_BodyLimit_LargerThanDefault(t *testing.T) { |
| 502 | t.Parallel() |
| 503 | |
| 504 | limit := DefaultBodyLimit*2 + 1024 // slightly above double the default |
| 505 | app := New(Config{BodyLimit: limit}) |
| 506 | |
| 507 | app.Post("/", func(c Ctx) error { |
| 508 | return c.SendStatus(StatusOK) |
| 509 | }) |
| 510 | |
| 511 | // Body larger than the default but within our custom limit should succeed |
| 512 | midBody := bytes.Repeat([]byte{'a'}, DefaultBodyLimit+512) |
| 513 | req := httptest.NewRequest(MethodPost, "/", bytes.NewReader(midBody)) |
| 514 | resp, err := app.Test(req) |
| 515 | require.NoError(t, err) |
| 516 | require.Equal(t, StatusOK, resp.StatusCode) |
| 517 | |
| 518 | // Body above the custom limit should fail |
| 519 | largeBody := bytes.Repeat([]byte{'a'}, limit+1) |
| 520 | req = httptest.NewRequest(MethodPost, "/", bytes.NewReader(largeBody)) |
| 521 | _, err = app.Test(req) |
| 522 | require.ErrorIs(t, err, fasthttp.ErrBodyTooLarge) |
| 523 | } |
| 524 | |
| 525 | type customConstraint struct{} |
| 526 |
nothing calls this directly
no test coverage detected