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

Function Test_Ctx_SaveFileToStorage_LargeUpload

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

Source from the content-addressed store, hash-verified

5581}
5582
5583func Test_Ctx_SaveFileToStorage_LargeUpload(t *testing.T) {
5584 t.Parallel()
5585 const (
5586 bodyLimit = 8 * 1024 * 1024
5587 fileSize = 5 * 1024 * 1024
5588 )
5589
5590 app := New(Config{BodyLimit: bodyLimit})
5591 storage := memory.New()
5592 ctx := app.AcquireCtx(&fasthttp.RequestCtx{})
5593
5594 t.Cleanup(func() {
5595 app.ReleaseCtx(ctx)
5596 })
5597
5598 fileHeader := createMultipartFileHeader(t, "large.bin", bytes.Repeat([]byte{'a'}, fileSize))
5599
5600 err := ctx.SaveFileToStorage(fileHeader, "test", storage)
5601 require.NoError(t, err)
5602
5603 stored, err := storage.Get("test")
5604 require.NoError(t, err)
5605 require.Len(t, stored, fileSize)
5606}
5607
5608func Test_Ctx_SaveFileToStorage_LimitExceeded(t *testing.T) {
5609 t.Parallel()

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected