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

Function Test_Integration_Domain_WithSession

app_integration_test.go:938–959  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

936}
937
938func Test_Integration_Domain_WithSession(t *testing.T) {
939 t.Parallel()
940
941 app := fiber.New()
942 app.Use(session.New())
943
944 app.Domain("api.example.com").Get("/session", func(c fiber.Ctx) error {
945 sess := session.FromContext(c)
946 if sess == nil {
947 return c.Status(fiber.StatusInternalServerError).SendString("no session")
948 }
949 sess.Set("domain", "api")
950 return c.SendString("session set")
951 })
952
953 req := httptest.NewRequest(http.MethodGet, "/session", http.NoBody)
954 req.Host = "api.example.com"
955 resp, err := app.Test(req)
956 require.NoError(t, err)
957 require.Equal(t, fiber.StatusOK, resp.StatusCode)
958 require.Contains(t, resp.Header.Get(fiber.HeaderSetCookie), "session_id=")
959}
960
961func Test_Integration_Domain_WithCompress(t *testing.T) {
962 t.Parallel()

Callers

nothing calls this directly

Calls 11

NewFunction · 0.92
FromContextFunction · 0.92
TestMethod · 0.80
ContainsMethod · 0.80
NewMethod · 0.65
UseMethod · 0.65
GetMethod · 0.65
DomainMethod · 0.65
SendStringMethod · 0.65
StatusMethod · 0.65
SetMethod · 0.65

Tested by

no test coverage detected