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

Function TestContext

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

Source from the content-addressed store, hash-verified

22)
23
24func 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
48func TestNamespaceFromEnv(t *testing.T) {
49 ctx := context.Background()

Callers

nothing calls this directly

Calls 3

FatalMethod · 0.80
NamespaceFunction · 0.70
WithNamespaceFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…