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

Function Test_Store_DeleteSession

middleware/session/store_test.go:97–125  ·  view source on GitHub ↗

go test -run Test_Store_DeleteSession

(t *testing.T)

Source from the content-addressed store, hash-verified

95
96// go test -run Test_Store_DeleteSession
97func Test_Store_DeleteSession(t *testing.T) {
98 t.Parallel()
99 // fiber instance
100 app := fiber.New()
101 // session store
102 store := NewStore()
103
104 // fiber context
105 ctx := app.AcquireCtx(&fasthttp.RequestCtx{})
106 defer app.ReleaseCtx(ctx)
107
108 // Create a new session
109 session, err := store.Get(ctx)
110 require.NoError(t, err)
111
112 // Save the session ID
113 sessionID := session.ID()
114
115 // Delete the session
116 err = store.Delete(ctx, sessionID)
117 require.NoError(t, err)
118
119 // Try to get the session again
120 session, err = store.Get(ctx)
121 require.NoError(t, err)
122
123 // The session ID should be different now, because the old session was deleted
124 require.NotEqual(t, sessionID, session.ID())
125}
126
127func TestStore_Get_SessionAlreadyLoaded(t *testing.T) {
128 // Create a new Fiber app

Callers

nothing calls this directly

Calls 7

GetMethod · 0.95
DeleteMethod · 0.95
NewStoreFunction · 0.85
AcquireCtxMethod · 0.80
ReleaseCtxMethod · 0.80
NewMethod · 0.65
IDMethod · 0.45

Tested by

no test coverage detected