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

Function Test_Session_ResolveContext

middleware/session/session_test.go:2033–2053  ·  view source on GitHub ↗

go test -run Test_Session_ResolveContext

(t *testing.T)

Source from the content-addressed store, hash-verified

2031
2032// go test -run Test_Session_ResolveContext
2033func Test_Session_ResolveContext(t *testing.T) {
2034 t.Parallel()
2035
2036 t.Run("resolve context returns background when ctx is nil", func(t *testing.T) {
2037 t.Parallel()
2038 sess := &Session{ctx: nil}
2039 ctx := sess.resolveContext()
2040 require.NotNil(t, ctx)
2041 })
2042
2043 t.Run("resolve context returns fiber context when ctx is not nil", func(t *testing.T) {
2044 t.Parallel()
2045 app := fiber.New()
2046 fctx := app.AcquireCtx(&fasthttp.RequestCtx{})
2047 defer app.ReleaseCtx(fctx)
2048
2049 sess := &Session{ctx: fctx}
2050 ctx := sess.resolveContext()
2051 require.Equal(t, fctx, ctx)
2052 })
2053}
2054
2055// newSessionWithStorage returns a fresh session backed by the given storage and
2056// a cleanup function that releases pooled resources. Because the request has no

Callers

nothing calls this directly

Calls 4

resolveContextMethod · 0.95
AcquireCtxMethod · 0.80
ReleaseCtxMethod · 0.80
NewMethod · 0.65

Tested by

no test coverage detected