(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…