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

Function Test_Ctx_SaveFileToStorage_StoreErrorIncludesPath

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

Source from the content-addressed store, hash-verified

5901}
5902
5903func Test_Ctx_SaveFileToStorage_StoreErrorIncludesPath(t *testing.T) {
5904 t.Parallel()
5905
5906 app := New()
5907 wantErr := errors.New("backend down")
5908 storage := &failingStorage{err: wantErr}
5909
5910 ctx := app.AcquireCtx(&fasthttp.RequestCtx{})
5911 defer app.ReleaseCtx(ctx)
5912
5913 fileHeader := createMultipartFileHeader(t, "report.pdf", []byte("payload"))
5914
5915 err := ctx.SaveFileToStorage(fileHeader, "uploads/report.pdf", storage)
5916
5917 require.Error(t, err)
5918 require.ErrorIs(t, err, ErrFileStore)
5919 require.ErrorIs(t, err, wantErr)
5920 require.Contains(t, err.Error(), "report.pdf")
5921 require.Contains(t, err.Error(), "uploads/report.pdf")
5922}
5923
5924type failingStorage struct {
5925 err error

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected