MCPcopy Create free account
hub / github.com/zalando/skipper / TestContext

Function TestContext

routing/context_test.go:9–21  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestContext(t *testing.T) {
10 m := &sync.Map{}
11 m.Store("foo", "bar")
12
13 ctx := NewContext(context.Background())
14 nctx := context.WithValue(ctx, routingContextKey, m)
15
16 defaultVal := func() string { return "default" }
17 val := FromContext(nctx, "foo", defaultVal)
18 if val != "bar" {
19 t.Fatalf("Failed to get value from context: %q", val)
20 }
21}
22
23func TestContextDefault(t *testing.T) {
24 ctx := context.Background()

Callers

nothing calls this directly

Calls 3

NewContextFunction · 0.85
FromContextFunction · 0.85
StoreMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…