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

Function Test_Session_Middleware_Store

middleware/session/middleware_test.go:638–662  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

636}
637
638func Test_Session_Middleware_Store(t *testing.T) {
639 t.Parallel()
640 app := fiber.New()
641
642 handler, sessionStore := NewWithStore()
643
644 app.Use(handler)
645
646 app.Get("/", func(c fiber.Ctx) error {
647 sess := FromContext(c)
648 st := sess.Store()
649 if st != sessionStore {
650 return c.SendStatus(fiber.StatusInternalServerError)
651 }
652 return c.SendStatus(fiber.StatusOK)
653 })
654
655 h := app.Handler()
656
657 // Test GET request
658 ctx := &fasthttp.RequestCtx{}
659 ctx.Request.Header.SetMethod(fiber.MethodGet)
660 h(ctx)
661 require.Equal(t, fiber.StatusOK, ctx.Response.StatusCode())
662}
663
664// failingStorage simulates a session store whose backend is unavailable.
665type failingStorage struct {

Callers

nothing calls this directly

Calls 10

NewWithStoreFunction · 0.85
StoreMethod · 0.80
HandlerMethod · 0.80
SetMethodMethod · 0.80
FromContextFunction · 0.70
NewMethod · 0.65
UseMethod · 0.65
GetMethod · 0.65
SendStatusMethod · 0.65
StatusCodeMethod · 0.45

Tested by

no test coverage detected