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

Function Test_Request_Context

client/request_test.go:79–96  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

77}
78
79func Test_Request_Context(t *testing.T) {
80 t.Parallel()
81
82 req := AcquireRequest()
83 ctx := req.Context()
84 type ctxKey struct{}
85 var key ctxKey = struct{}{}
86
87 require.Nil(t, ctx.Value(key))
88
89 ctx = context.WithValue(ctx, key, "string")
90 req.SetContext(ctx)
91 ctx = req.Context()
92
93 v, ok := ctx.Value(key).(string)
94 require.True(t, ok)
95 require.Equal(t, "string", v)
96}
97
98func Test_Request_Header(t *testing.T) {
99 t.Parallel()

Callers

nothing calls this directly

Calls 4

AcquireRequestFunction · 0.85
ContextMethod · 0.65
ValueMethod · 0.65
SetContextMethod · 0.65

Tested by

no test coverage detected