(t *testing.T)
| 7 | ) |
| 8 | |
| 9 | func 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 | |
| 23 | func TestContextDefault(t *testing.T) { |
| 24 | ctx := context.Background() |
nothing calls this directly
no test coverage detected
searching dependent graphs…