MCPcopy Index your code
hub / github.com/containerd/containerd / TestNamespaceFromEnv

Function TestNamespaceFromEnv

pkg/namespaces/context_test.go:48–71  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

46}
47
48func TestNamespaceFromEnv(t *testing.T) {
49 ctx := context.Background()
50 namespace, ok := Namespace(ctx)
51 if ok {
52 t.Fatal("namespace should not be present")
53 }
54
55 if namespace != "" {
56 t.Fatalf("namespace should not be defined: got %q", namespace)
57 }
58
59 expected := "test-namespace"
60 t.Setenv(NamespaceEnvVar, expected)
61 nctx := NamespaceFromEnv(ctx)
62
63 namespace, ok = Namespace(nctx)
64 if !ok {
65 t.Fatal("expected to find a namespace")
66 }
67
68 if namespace != expected {
69 t.Fatalf("unexpected namespace: %q != %q", namespace, expected)
70 }
71}

Callers

nothing calls this directly

Calls 3

NamespaceFromEnvFunction · 0.85
FatalMethod · 0.80
NamespaceFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…