(t *testing.T)
| 454 | } |
| 455 | |
| 456 | func 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 | |
| 480 | func Test_App_BodyLimit_Zero(t *testing.T) { |
| 481 | t.Parallel() |
nothing calls this directly
no test coverage detected