MCPcopy
hub / github.com/containerd/containerd / TestSandboxUpdate

Function TestSandboxUpdate

core/metadata/sandbox_test.go:84–130  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

82}
83
84func TestSandboxUpdate(t *testing.T) {
85 ctx, db := testDB(t)
86 store := NewSandboxStore(db)
87
88 if _, err := store.Create(ctx, api.Sandbox{
89 ID: "2",
90 Labels: map[string]string{"lbl1": "existing"},
91 Spec: &types.Any{TypeUrl: "1", Value: []byte{1}}, // will replace
92 Extensions: map[string]typeurl.Any{
93 "ext2": &types.Any{TypeUrl: "url2", Value: []byte{4, 5, 6}}, // will append `ext1`
94 },
95 Runtime: api.RuntimeOpts{Name: "test"}, // no change
96 Sandboxer: "test-sandboxer", // no change
97 }); err != nil {
98 t.Fatal(err)
99 }
100
101 expectedSpec := types.Any{TypeUrl: "2", Value: []byte{3, 2, 1}}
102
103 out, err := store.Update(ctx, api.Sandbox{
104 ID: "2",
105 Labels: map[string]string{"lbl1": "new"},
106 Spec: &expectedSpec,
107 Extensions: map[string]typeurl.Any{
108 "ext1": &types.Any{TypeUrl: "url1", Value: []byte{1, 2}},
109 },
110 }, "labels.lbl1", "extensions.ext1", "spec")
111 if err != nil {
112 t.Fatal(err)
113 }
114
115 expected := api.Sandbox{
116 ID: "2",
117 Spec: &expectedSpec,
118 Labels: map[string]string{
119 "lbl1": "new",
120 },
121 Extensions: map[string]typeurl.Any{
122 "ext1": &types.Any{TypeUrl: "url1", Value: []byte{1, 2}},
123 "ext2": &types.Any{TypeUrl: "url2", Value: []byte{4, 5, 6}},
124 },
125 Runtime: api.RuntimeOpts{Name: "test"},
126 Sandboxer: "test-sandboxer",
127 }
128
129 assertEqualInstances(t, out, expected)
130}
131
132func TestSandboxGetInvalid(t *testing.T) {
133 ctx, db := testDB(t)

Callers

nothing calls this directly

Calls 6

assertEqualInstancesFunction · 0.85
FatalMethod · 0.80
testDBFunction · 0.70
NewSandboxStoreFunction · 0.70
CreateMethod · 0.65
UpdateMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…