MCPcopy
hub / github.com/zarf-dev/zarf / TestUnpackMultipleImages

Function TestUnpackMultipleImages

src/pkg/images/unpack_test.go:201–304  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

199}
200
201func TestUnpackMultipleImages(t *testing.T) {
202 t.Parallel()
203
204 testCases := []struct {
205 name string
206 srcDir string
207 requestedImages []string
208 expectErr error
209 }{
210 {
211 name: "single image, docker image store",
212 srcDir: filepath.Join("testdata", "docker-graph-driver-image-store"),
213 requestedImages: []string{
214 "docker.io/library/hello-world:linux",
215 },
216 },
217 {
218 name: "single image, docker containerd store",
219 srcDir: filepath.Join("testdata", "docker-containerd-image-store"),
220 requestedImages: []string{
221 "docker.io/library/hello-world:linux",
222 },
223 },
224 {
225 name: "pull several images, including non-container images",
226 srcDir: filepath.Join("testdata", "oras-oci-layout", "images"),
227 requestedImages: []string{
228 "docker.io/library/hello-world@sha256:03b62250a3cb1abd125271d393fc08bf0cc713391eda6b57c02d1ef85efcc25c",
229 "ghcr.io/zarf-dev/images/hello-world:latest",
230 "ghcr.io/stefanprodan/podinfo:sha256-57a654ace69ec02ba8973093b6a786faa15640575fbf0dbb603db55aca2ccec8.sig",
231 "localhost:9999/local-test:1.0.0",
232 "docker.io/library/local-test:1.0.0",
233 "ghcr.io/stefanprodan/charts/podinfo:6.4.0",
234 },
235 },
236 {
237 name: "non-existent image",
238 srcDir: filepath.Join("testdata", "docker-graph-driver-image-store"),
239 requestedImages: []string{
240 "docker.io/library/hello-world:linux",
241 "docker.io/library/non-existent-image:linux",
242 },
243 expectErr: errors.New("could not find image docker.io/library/non-existent-image:linux"),
244 },
245 }
246
247 for _, tc := range testCases {
248 t.Run(tc.name, func(t *testing.T) {
249 t.Parallel()
250 ctx := testutil.TestContext(t)
251
252 // Create a tar from the source directory
253 tarFile := filepath.Join(t.TempDir(), "images.tar")
254 err := archive.Compress(ctx, []string{tc.srcDir}, tarFile, archive.CompressOpts{})
255 require.NoError(t, err)
256 dstDir := t.TempDir()
257 imageArchives := v1alpha1.ImageArchive{
258 Path: tarFile,

Callers

nothing calls this directly

Calls 7

TestContextFunction · 0.92
CompressFunction · 0.92
UnpackFunction · 0.85
getIndexFromOCILayoutFunction · 0.85
IsManifestFunction · 0.85
RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected