integration/image: migrate TestAPIImagesDelete to the new integration test framework

Migrated TestAPIImagesDelete from the legacy integration-cli suite
(docker_api_images_test.go) to the new integration test framework under
integration/image/remove_test.go.

This update:
- Fixes ENV instruction syntax to use "ENV FOO=bar"
- Adds error type check using errdefs.IsNotFound for cleaner assertions
- Ensures consistent cleanup handling

Signed-off-by: Aditya Mishra <mishraaditya675@gmail.com>
This commit is contained in:
Aditya Mishra
2025-11-12 21:09:41 +05:30
parent 27cefe6c43
commit 8f1134b46d
2 changed files with 39 additions and 24 deletions

View File

@@ -36,30 +36,6 @@ func (s *DockerAPISuite) TestAPIImagesSaveAndLoad(c *testing.T) {
assert.Equal(c, strings.TrimSpace(inspectOut), id, "load did not work properly")
}
func (s *DockerAPISuite) TestAPIImagesDelete(c *testing.T) {
apiClient, err := client.New(client.FromEnv)
assert.NilError(c, err)
defer apiClient.Close()
if testEnv.DaemonInfo.OSType != "windows" {
testRequires(c, Network)
}
name := "test-api-images-delete"
cli.BuildCmd(c, name, build.WithDockerfile("FROM busybox\nENV FOO bar"))
id := getIDByName(c, name)
cli.DockerCmd(c, "tag", name, "test:tag1")
_, err = apiClient.ImageRemove(testutil.GetContext(c), id, client.ImageRemoveOptions{})
assert.ErrorContains(c, err, "unable to delete")
_, err = apiClient.ImageRemove(testutil.GetContext(c), "test:noexist", client.ImageRemoveOptions{})
assert.ErrorContains(c, err, "No such image")
_, err = apiClient.ImageRemove(testutil.GetContext(c), "test:tag1", client.ImageRemoveOptions{})
assert.NilError(c, err)
}
func (s *DockerAPISuite) TestAPIImagesImportBadSrc(c *testing.T) {
testRequires(c, Network, testEnv.IsLocalDaemon)