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

Function TestRemoveImages

libimage/remove_test.go:12–44  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestRemoveImages(t *testing.T) {
13 // Note: this will resolve pull from the GCR registry (see
14 // testdata/registries.conf).
15 busyboxLatest := "docker.io/library/busybox:latest"
16
17 runtime, cleanup := testNewRuntime(t)
18 defer cleanup()
19 ctx := context.Background()
20
21 pullOptions := &PullOptions{}
22 pullOptions.Writer = os.Stdout
23 pulledImages, err := runtime.Pull(ctx, busyboxLatest, config.PullPolicyAlways, pullOptions)
24 require.NoError(t, err)
25 require.Len(t, pulledImages, 1)
26
27 err = pulledImages[0].Tag("foobar")
28 require.NoError(t, err)
29
30 // containers/podman/issues/10685 - force removal on image with
31 // multiple tags will only untag but not remove all tags including the
32 // image.
33 rmReports, rmErrors := runtime.RemoveImages(ctx, []string{"foobar"}, &RemoveImagesOptions{Force: true})
34 require.Nil(t, rmErrors)
35 require.Len(t, rmReports, 1)
36 require.Equal(t, pulledImages[0].ID(), rmReports[0].ID)
37 require.False(t, rmReports[0].Removed)
38 require.Equal(t, []string{"localhost/foobar:latest"}, rmReports[0].Untagged)
39
40 // The busybox image is still present even if foobar was force removed.
41 exists, err := runtime.Exists(busyboxLatest)
42 require.NoError(t, err)
43 require.True(t, exists)
44}

Callers

nothing calls this directly

Calls 8

testNewRuntimeFunction · 0.85
PullMethod · 0.80
TagMethod · 0.80
RemoveImagesMethod · 0.80
ExistsMethod · 0.80
LenMethod · 0.65
cleanupFunction · 0.50
IDMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…