Test_Session_Next() — fiber Function Reference
Architecture documentation for the Test_Session_Next() function in middleware_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD dd7f05cc_0458_4dc1_b6cc_7fab2cb48a3d["Test_Session_Next()"] 7a9a2d4e_2e85_3a21_3ac8_2223cd90e48f["middleware_test.go"] dd7f05cc_0458_4dc1_b6cc_7fab2cb48a3d -->|defined in| 7a9a2d4e_2e85_3a21_3ac8_2223cd90e48f style dd7f05cc_0458_4dc1_b6cc_7fab2cb48a3d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
middleware/session/middleware_test.go lines 492–543
func Test_Session_Next(t *testing.T) {
t.Parallel()
var (
doNext bool
muNext sync.RWMutex
)
app := fiber.New()
app.Use(New(Config{
Next: func(_ fiber.Ctx) bool {
muNext.RLock()
defer muNext.RUnlock()
return doNext
},
}))
app.Get("/", func(c fiber.Ctx) error {
sess := FromContext(c)
if sess == nil {
return c.SendStatus(fiber.StatusInternalServerError)
}
id := sess.ID()
return c.SendString("value=" + id)
})
h := app.Handler()
// Test with Next returning false
ctx := &fasthttp.RequestCtx{}
ctx.Request.Header.SetMethod(fiber.MethodGet)
h(ctx)
require.Equal(t, fiber.StatusOK, ctx.Response.StatusCode())
// Get session cookie
token := string(ctx.Response.Header.Peek(fiber.HeaderSetCookie))
require.NotEmpty(t, token, "Expected Set-Cookie header to be present")
tokenParts := strings.SplitN(strings.SplitN(token, ";", 2)[0], "=", 2)
require.Len(t, tokenParts, 2, "Expected Set-Cookie header to contain a token")
token = tokenParts[1]
require.Equal(t, "value="+token, string(ctx.Response.Body()))
// Test with Next returning true
muNext.Lock()
doNext = true
muNext.Unlock()
ctx = &fasthttp.RequestCtx{}
ctx.Request.Header.SetMethod(fiber.MethodGet)
h(ctx)
require.Equal(t, fiber.StatusInternalServerError, ctx.Response.StatusCode())
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does Test_Session_Next() do?
Test_Session_Next() is a function in the fiber codebase, defined in middleware/session/middleware_test.go.
Where is Test_Session_Next() defined?
Test_Session_Next() is defined in middleware/session/middleware_test.go at line 492.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free