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

Function TestStoreInContext

helpers_test.go:1667–1684  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1665}
1666
1667func TestStoreInContext(t *testing.T) {
1668 t.Parallel()
1669
1670 app := New(Config{PassLocalsToContext: true})
1671 raw := &fasthttp.RequestCtx{}
1672 c := app.AcquireCtx(raw)
1673 defer app.ReleaseCtx(c)
1674
1675 StoreInContext(c, "key", "value")
1676
1677 localValue, ok := c.Locals("key").(string)
1678 require.True(t, ok)
1679 require.Equal(t, "value", localValue)
1680
1681 contextValue, ok := c.Context().Value("key").(string)
1682 require.True(t, ok)
1683 require.Equal(t, "value", contextValue)
1684}
1685
1686func TestValueFromContext(t *testing.T) {
1687 t.Parallel()

Callers

nothing calls this directly

Calls 7

StoreInContextFunction · 0.85
AcquireCtxMethod · 0.80
ReleaseCtxMethod · 0.80
NewFunction · 0.70
LocalsMethod · 0.65
ValueMethod · 0.65
ContextMethod · 0.65

Tested by

no test coverage detected