MCPcopy Create free account
hub / github.com/containers/common / TestPullPlatforms

Function TestPullPlatforms

libimage/pull_test.go:81–139  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

79}
80
81func TestPullPlatforms(t *testing.T) {
82 runtime, cleanup := testNewRuntime(t)
83 defer cleanup()
84 ctx := context.Background()
85 pullOptions := &PullOptions{}
86 pullOptions.Writer = os.Stdout
87
88 localArch := goruntime.GOARCH
89 localOS := goruntime.GOOS
90
91 withTag := "busybox:musl"
92
93 pulledImages, err := runtime.Pull(ctx, withTag, config.PullPolicyAlways, pullOptions)
94 require.NoError(t, err, "pull busybox")
95 require.Len(t, pulledImages, 1)
96
97 // Repulling with a bogus architecture should yield an error and not
98 // choose the local image.
99 pullOptions.Architecture = "bogus"
100 _, err = runtime.Pull(ctx, withTag, config.PullPolicyNewer, pullOptions)
101 require.Error(t, err, "pulling with a bogus architecture must fail even if there is a local image of another architecture")
102 require.Contains(t, err.Error(), "no image found in manifest list for architecture bogus")
103
104 image, _, err := runtime.LookupImage(withTag, nil)
105 require.NoError(t, err, "lookup busybox")
106 require.NotNil(t, image, "lookup busybox")
107
108 _, _, err = runtime.LookupImage("busybox", nil)
109 require.Error(t, err, "untagged image resolves to non-existent :latest")
110
111 image, _, err = runtime.LookupImage(withTag, &LookupImageOptions{Architecture: localArch})
112 require.NoError(t, err, "lookup busybox - by local arch")
113 require.NotNil(t, image, "lookup busybox - by local arch")
114
115 image, _, err = runtime.LookupImage(withTag, &LookupImageOptions{OS: localOS})
116 require.NoError(t, err, "lookup busybox - by local arch")
117 require.NotNil(t, image, "lookup busybox - by local arch")
118
119 _, _, err = runtime.LookupImage(withTag, &LookupImageOptions{Architecture: "bogus"})
120 require.Error(t, err, "lookup busybox - bogus arch")
121
122 _, _, err = runtime.LookupImage(withTag, &LookupImageOptions{OS: "bogus"})
123 require.Error(t, err, "lookup busybox - bogus OS")
124
125 pullOptions.Architecture = "arm"
126 pulledImages, err = runtime.Pull(ctx, withTag, config.PullPolicyAlways, pullOptions)
127 require.NoError(t, err, "pull busybox - arm")
128 require.Len(t, pulledImages, 1)
129 pullOptions.Architecture = ""
130
131 image, _, err = runtime.LookupImage(withTag, &LookupImageOptions{Architecture: "arm"})
132 require.NoError(t, err, "lookup busybox - by arm")
133 require.NotNil(t, image, "lookup busybox - by arm")
134
135 pullOptions.Architecture = "aarch64"
136 pulledImages, err = runtime.Pull(ctx, withTag, config.PullPolicyAlways, pullOptions)
137 require.NoError(t, err, "pull busybox - aarch64")
138 require.Len(t, pulledImages, 1)

Callers

nothing calls this directly

Calls 6

testNewRuntimeFunction · 0.85
PullMethod · 0.80
LookupImageMethod · 0.80
LenMethod · 0.65
cleanupFunction · 0.50
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…