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

Function Test_SessionManager_SetRaw_StoreError

middleware/csrf/csrf_test.go:2923–2941  ·  view source on GitHub ↗

Test_SessionManager_SetRaw_StoreError covers the error branch when the session store cannot be loaded during setRaw.

(t *testing.T)

Source from the content-addressed store, hash-verified

2921// Test_SessionManager_SetRaw_StoreError covers the error branch when the session
2922// store cannot be loaded during setRaw.
2923func Test_SessionManager_SetRaw_StoreError(t *testing.T) {
2924 t.Parallel()
2925
2926 storage := newFlakySessionStorage()
2927 storage.failGet = true
2928 store := session.NewStore(session.Config{
2929 Storage: storage,
2930 Extractor: extractors.FromCookie("session_id"),
2931 })
2932 m := newSessionManager(store)
2933
2934 app := fiber.New()
2935 c := newSessionCtx(app, "abc")
2936 defer app.ReleaseCtx(c)
2937
2938 require.NotPanics(t, func() {
2939 m.setRaw(c, "key", dummyValue, time.Minute)
2940 })
2941}
2942
2943// Test_SessionManager_SetRaw_SaveError covers the save-failure warning branch of
2944// setRaw, where the store loads successfully but persisting it fails.

Callers

nothing calls this directly

Calls 8

NewStoreFunction · 0.92
FromCookieFunction · 0.92
newFlakySessionStorageFunction · 0.85
newSessionManagerFunction · 0.85
newSessionCtxFunction · 0.85
ReleaseCtxMethod · 0.80
NewMethod · 0.65
setRawMethod · 0.45

Tested by

no test coverage detected