MCPcopy Create free account
hub / github.com/docker/cli / TestMetadataCreateGetRemove

Function TestMetadataCreateGetRemove

cli/context/store/metadata_test.go:32–64  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

30}
31
32func TestMetadataCreateGetRemove(t *testing.T) {
33 testDir := t.TempDir()
34 testee := metadataStore{root: testDir, config: testCfg}
35 expected2 := Metadata{
36 Endpoints: map[string]any{
37 "ep1": endpoint{Foo: "baz"},
38 "ep2": endpoint{Foo: "bee"},
39 },
40 Metadata: context{Bar: "foo"},
41 Name: "test-context",
42 }
43 testMeta := testMetadata("test-context")
44 err := testee.createOrUpdate(testMeta)
45 assert.NilError(t, err)
46 // create a new instance to check it does not depend on some sort of state
47 testee = metadataStore{root: testDir, config: testCfg}
48 meta, err := testee.get("test-context")
49 assert.NilError(t, err)
50 assert.DeepEqual(t, meta, testMeta)
51
52 // update
53
54 err = testee.createOrUpdate(expected2)
55 assert.NilError(t, err)
56 meta, err = testee.get("test-context")
57 assert.NilError(t, err)
58 assert.DeepEqual(t, meta, expected2)
59
60 assert.NilError(t, testee.remove("test-context"))
61 assert.NilError(t, testee.remove("test-context")) // support duplicate remove
62 _, err = testee.get("test-context")
63 assert.ErrorType(t, err, errdefs.IsNotFound)
64}
65
66func TestMetadataRespectJsonAnnotation(t *testing.T) {
67 testDir := t.TempDir()

Callers

nothing calls this directly

Calls 4

createOrUpdateMethod · 0.95
getMethod · 0.95
removeMethod · 0.95
testMetadataFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…