(t *testing.T)
| 22 | ) |
| 23 | |
| 24 | func TestContext(t *testing.T) { |
| 25 | ctx := context.Background() |
| 26 | namespace, ok := Namespace(ctx) |
| 27 | if ok { |
| 28 | t.Fatal("namespace should not be present") |
| 29 | } |
| 30 | |
| 31 | if namespace != "" { |
| 32 | t.Fatalf("namespace should not be defined: got %q", namespace) |
| 33 | } |
| 34 | |
| 35 | expected := "test" |
| 36 | nctx := WithNamespace(ctx, expected) |
| 37 | |
| 38 | namespace, ok = Namespace(nctx) |
| 39 | if !ok { |
| 40 | t.Fatal("expected to find a namespace") |
| 41 | } |
| 42 | |
| 43 | if namespace != expected { |
| 44 | t.Fatalf("unexpected namespace: %q != %q", namespace, expected) |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | func TestNamespaceFromEnv(t *testing.T) { |
| 49 | ctx := context.Background() |
nothing calls this directly
no test coverage detected
searching dependent graphs…