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

Function TestStoreSaveAndGet

cli/manifest/store/store_test.go:55–97  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

53}
54
55func TestStoreSaveAndGet(t *testing.T) {
56 store := NewStore(t.TempDir())
57 listRef := ref("list")
58 data := types.ImageManifest{Ref: sref(t, "abcdef")}
59 err := store.Save(listRef, ref("exists"), data)
60 assert.NilError(t, err)
61
62 testcases := []struct {
63 listRef reference.Reference
64 manifestRef reference.Reference
65 expected types.ImageManifest
66 expectedErr string
67 }{
68 {
69 listRef: listRef,
70 manifestRef: ref("exists"),
71 expected: data,
72 },
73 {
74 listRef: listRef,
75 manifestRef: ref("exist:does-not"),
76 expectedErr: "No such manifest: exist:does-not",
77 },
78 {
79 listRef: ref("list:does-not-exist"),
80 manifestRef: ref("manifest:does-not-exist"),
81 expectedErr: "No such manifest: manifest:does-not-exist",
82 },
83 }
84
85 for _, tc := range testcases {
86 t.Run(tc.manifestRef.String(), func(t *testing.T) {
87 actual, err := store.Get(tc.listRef, tc.manifestRef)
88 if tc.expectedErr != "" {
89 assert.Error(t, err, tc.expectedErr)
90 assert.Check(t, errdefs.IsNotFound(err))
91 return
92 }
93 assert.NilError(t, err)
94 assert.DeepEqual(t, tc.expected, actual, cmpReferenceNamed)
95 })
96 }
97}
98
99var cmpReferenceNamed = cmp.Transformer("namedref", func(r reference.Named) string {
100 return r.String()

Callers

nothing calls this directly

Calls 7

SaveMethod · 0.95
GetMethod · 0.95
NewStoreFunction · 0.85
srefFunction · 0.85
refFunction · 0.70
StringMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…