MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / TestFillContext

Function TestFillContext

pkg/webmiddleware/fillcontext_test.go:28–43  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

26)
27
28func TestFillContext(t *testing.T) {
29 a := assertions.New(t)
30
31 type ctxKeyType struct{}
32 var ctxKey ctxKeyType
33
34 m := FillContext(func(ctx context.Context) context.Context {
35 return context.WithValue(ctx, ctxKey, "value")
36 })
37
38 r := httptest.NewRequest(http.MethodGet, "/", nil)
39 rec := httptest.NewRecorder()
40 m(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
41 a.So(r.Context().Value(ctxKey), should.Equal, "value")
42 })).ServeHTTP(rec, r)
43}

Callers

nothing calls this directly

Calls 5

FillContextFunction · 0.85
NewMethod · 0.65
ContextMethod · 0.65
ServeHTTPMethod · 0.45
ValueMethod · 0.45

Tested by

no test coverage detected