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

Function Test_Ctx_SaveFileToStorage_LimitExceededUnknownSize

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

Source from the content-addressed store, hash-verified

5628}
5629
5630func Test_Ctx_SaveFileToStorage_LimitExceededUnknownSize(t *testing.T) {
5631 t.Parallel()
5632 const (
5633 allowedSize = 1024
5634 fileSize = allowedSize + 256
5635 )
5636
5637 app := New(Config{BodyLimit: allowedSize})
5638
5639 storage := memory.New()
5640 ctx := app.AcquireCtx(&fasthttp.RequestCtx{})
5641
5642 t.Cleanup(func() {
5643 app.ReleaseCtx(ctx)
5644 })
5645
5646 fileHeader := createMultipartFileHeader(t, "unknown-size.bin", bytes.Repeat([]byte{'a'}, fileSize))
5647 fileHeader.Size = -1
5648
5649 err := ctx.SaveFileToStorage(fileHeader, "test", storage)
5650 require.ErrorIs(t, err, fasthttp.ErrBodyTooLarge)
5651}
5652
5653type captureStorage struct {
5654 t *testing.T

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