MCPcopy
hub / github.com/containerd/containerd / TestContainersCreateUpdateDelete

Function TestContainersCreateUpdateDelete

core/metadata/containers_test.go:174–676  ·  view source on GitHub ↗

TestContainersUpdate ensures that updates are taken in an expected manner.

(t *testing.T)

Source from the content-addressed store, hash-verified

172
173// TestContainersUpdate ensures that updates are taken in an expected manner.
174func TestContainersCreateUpdateDelete(t *testing.T) {
175 var (
176 ctx, db = testEnv(t)
177 store = NewContainerStore(NewDB(db, nil, nil))
178 spec = &specs.Spec{}
179 )
180
181 encoded, err := typeurl.MarshalAnyToProto(spec)
182 require.NoError(t, err)
183
184 spec.Annotations = map[string]string{"updated": "true"}
185 encodedUpdated, err := typeurl.MarshalAnyToProto(spec)
186 require.NoError(t, err)
187
188 for _, testcase := range []struct {
189 name string
190 original containers.Container
191 createerr error
192 input containers.Container
193 fieldpaths []string
194 expected containers.Container
195 cause error
196 }{
197 {
198 name: "UpdateIDFail",
199 original: containers.Container{
200 Spec: encoded,
201 SnapshotKey: "test-snapshot-key",
202 Snapshotter: "snapshotter",
203 Runtime: containers.RuntimeInfo{
204 Name: "testruntime",
205 },
206 },
207 input: containers.Container{
208 ID: "newid",
209 Spec: encoded,
210 Runtime: containers.RuntimeInfo{
211 Name: "testruntime",
212 },
213 },
214 fieldpaths: []string{"id"},
215 cause: errdefs.ErrNotFound,
216 },
217 {
218 name: "UpdateRuntimeFail",
219 original: containers.Container{
220 SnapshotKey: "test-snapshot-key",
221 Snapshotter: "snapshotter",
222 Spec: encoded,
223 Runtime: containers.RuntimeInfo{
224 Name: "testruntime",
225 },
226 },
227 input: containers.Container{
228 Spec: encoded,
229 Runtime: containers.RuntimeInfo{
230 Name: "testruntimedifferent",
231 },

Callers

nothing calls this directly

Calls 11

NewContainerStoreFunction · 0.85
NewDBFunction · 0.85
checkContainerTimestampsFunction · 0.85
checkContainersEqualFunction · 0.85
UnwrapMethod · 0.80
FatalMethod · 0.80
testEnvFunction · 0.70
RunMethod · 0.65
CreateMethod · 0.65
UpdateMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…