TestContainersUpdate ensures that updates are taken in an expected manner.
(t *testing.T)
| 172 | |
| 173 | // TestContainersUpdate ensures that updates are taken in an expected manner. |
| 174 | func 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 | }, |
nothing calls this directly
no test coverage detected
searching dependent graphs…