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

Function Test_SessionManager_SetRaw_SaveError

middleware/csrf/csrf_test.go:2945–2964  ·  view source on GitHub ↗

Test_SessionManager_SetRaw_SaveError covers the save-failure warning branch of setRaw, where the store loads successfully but persisting it fails.

(t *testing.T)

Source from the content-addressed store, hash-verified

2943// Test_SessionManager_SetRaw_SaveError covers the save-failure warning branch of
2944// setRaw, where the store loads successfully but persisting it fails.
2945func Test_SessionManager_SetRaw_SaveError(t *testing.T) {
2946 var buf bytes.Buffer
2947 fiberlog.SetOutput(&buf)
2948 t.Cleanup(func() { fiberlog.SetOutput(os.Stderr) })
2949
2950 storage := newFlakySessionStorage()
2951 storage.failSet = true
2952 store := session.NewStore(session.Config{
2953 Storage: storage,
2954 Extractor: extractors.FromCookie("session_id"),
2955 })
2956 m := newSessionManager(store)
2957
2958 app := fiber.New()
2959 c := newSessionCtx(app, "")
2960 defer app.ReleaseCtx(c)
2961
2962 m.setRaw(c, "key", dummyValue, time.Minute)
2963 require.Contains(t, buf.String(), "failed to save session")
2964}
2965
2966// Test_SessionManager_DelRaw_StoreError covers the error branch when the session
2967// store cannot be loaded during delRaw.

Callers

nothing calls this directly

Calls 11

StringMethod · 0.95
NewStoreFunction · 0.92
FromCookieFunction · 0.92
newFlakySessionStorageFunction · 0.85
newSessionManagerFunction · 0.85
newSessionCtxFunction · 0.85
ReleaseCtxMethod · 0.80
ContainsMethod · 0.80
SetOutputMethod · 0.65
NewMethod · 0.65
setRawMethod · 0.45

Tested by

no test coverage detected