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

Function Test_Ctx_SaveFileToStorage_LimitExceeded

ctx_test.go:5608–5628  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

5606}
5607
5608func Test_Ctx_SaveFileToStorage_LimitExceeded(t *testing.T) {
5609 t.Parallel()
5610 const (
5611 allowedSize = 1024
5612 fileSize = allowedSize + 512
5613 )
5614
5615 app := New(Config{BodyLimit: allowedSize})
5616
5617 storage := memory.New()
5618 ctx := app.AcquireCtx(&fasthttp.RequestCtx{})
5619
5620 t.Cleanup(func() {
5621 app.ReleaseCtx(ctx)
5622 })
5623
5624 fileHeader := createMultipartFileHeader(t, "too-large.bin", bytes.Repeat([]byte{'a'}, fileSize))
5625
5626 err := ctx.SaveFileToStorage(fileHeader, "test", storage)
5627 require.ErrorIs(t, err, fasthttp.ErrBodyTooLarge)
5628}
5629
5630func Test_Ctx_SaveFileToStorage_LimitExceededUnknownSize(t *testing.T) {
5631 t.Parallel()

Callers

nothing calls this directly

Calls 6

NewFunction · 0.92
AcquireCtxMethod · 0.80
ReleaseCtxMethod · 0.80
NewFunction · 0.70
SaveFileToStorageMethod · 0.65

Tested by

no test coverage detected