MCPcopy
hub / github.com/google/go-containerregistry / TestCopy

Function TestCopy

pkg/gcrane/copy_test.go:135–203  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

133}
134
135func TestCopy(t *testing.T) {
136 logs.Warn.SetOutput(os.Stderr)
137 xcr := newFakeXCR(t)
138 s := httptest.NewServer(xcr)
139 u, err := url.Parse(s.URL)
140 if err != nil {
141 t.Fatal(err)
142 }
143 defer s.Close()
144 src := path.Join(u.Host, "test/gcrane")
145 dst := path.Join(u.Host, "test/gcrane/copy")
146
147 oneTag, err := random.Image(1024, 5)
148 if err != nil {
149 t.Fatal(err)
150 }
151 twoTags, err := random.Image(1024, 5)
152 if err != nil {
153 t.Fatal(err)
154 }
155 noTags, err := random.Image(1024, 3)
156 if err != nil {
157 t.Fatal(err)
158 }
159
160 latestRef, err := name.ParseReference(src)
161 if err != nil {
162 t.Fatal(err)
163 }
164 oneTagRef := latestRef.Context().Tag("bar")
165
166 d, err := noTags.Digest()
167 if err != nil {
168 t.Fatal(err)
169 }
170 noTagsRef := latestRef.Context().Digest(d.String())
171 fooRef := latestRef.Context().Tag("foo")
172
173 // Populate this after we create it so we know the hostname.
174 if err := xcr.setRefs(map[name.Reference]partial.Describable{
175 oneTagRef: oneTag,
176 latestRef: twoTags,
177 fooRef: twoTags,
178 noTagsRef: noTags,
179 }); err != nil {
180 t.Fatal(err)
181 }
182
183 if err := remote.Write(latestRef, twoTags); err != nil {
184 t.Fatal(err)
185 }
186 if err := remote.Write(fooRef, twoTags); err != nil {
187 t.Fatal(err)
188 }
189 if err := remote.Write(oneTagRef, oneTag); err != nil {
190 t.Fatal(err)
191 }
192 if err := remote.Write(noTagsRef, noTags); err != nil {

Callers

nothing calls this directly

Calls 12

ImageFunction · 0.92
ParseReferenceFunction · 0.92
WriteFunction · 0.92
newFakeXCRFunction · 0.85
TagMethod · 0.80
setRefsMethod · 0.80
CopyFunction · 0.70
CopyRepositoryFunction · 0.70
CloseMethod · 0.65
ContextMethod · 0.65
DigestMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…