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

Function Test_Ctx_SaveFileToStorage_ErrorMessageContainsFilename

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

Source from the content-addressed store, hash-verified

5878}
5879
5880func Test_Ctx_SaveFileToStorage_ErrorMessageContainsFilename(t *testing.T) {
5881 t.Parallel()
5882
5883 app := New(Config{BodyLimit: 10}) // small limit to force error
5884 storage := memory.New()
5885
5886 ctx := app.AcquireCtx(&fasthttp.RequestCtx{})
5887 defer app.ReleaseCtx(ctx)
5888
5889 fileHeader := createMultipartFileHeader(
5890 t,
5891 "test-file.png",
5892 bytes.Repeat([]byte{'a'}, 100), // bigger than limit
5893 )
5894
5895 err := ctx.SaveFileToStorage(fileHeader, "test-path", storage)
5896
5897 require.Error(t, err)
5898 require.ErrorIs(t, err, ErrFileRead)
5899 require.ErrorIs(t, err, fasthttp.ErrBodyTooLarge)
5900 require.Contains(t, err.Error(), "test-file.png")
5901}
5902
5903func Test_Ctx_SaveFileToStorage_StoreErrorIncludesPath(t *testing.T) {
5904 t.Parallel()

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected