Skip to content

Test api images delete#51498

Merged
thaJeztah merged 1 commit intomoby:masterfrom
2003Aditya:TestAPIImagesDelete
Nov 16, 2025
Merged

Test api images delete#51498
thaJeztah merged 1 commit intomoby:masterfrom
2003Aditya:TestAPIImagesDelete

Conversation

@2003Aditya
Copy link
Contributor

- What I did
Migrated the TestAPIImagesDelete test from integration-cli/docker_api_images_test.go to the new integration test framework under integration/image/remove_test.go.

- How to verify it
TESTFLAGS='-test.run TestAPIImagesDelete' make test-integration

- Human readable description for the release notes
Migrate TestAPIImagesDelete from integration-cli to the new integration test framework.

@robmry
Copy link
Contributor

robmry commented Nov 12, 2025

Thank you @2003Aditya - looks like it worked on Windows, so that's great.

gofmt found an issue, spaces instead of tabs I think?

In the commit message's Signed-off-by, please could you use your name (rather than username).

You can squash and force-push the changes.

@robmry robmry added kind/refactor PR's that refactor, or clean-up code and removed area/docs labels Nov 12, 2025
assert.Check(t, is.ErrorContains(err, "unable to delete"))

_, err = apiClient.ImageRemove(ctx, "test:noexist", client.ImageRemoveOptions{})
assert.Check(t, is.ErrorContains(err, "No such image"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not critical (can be a follow up) but perhaps we should update this to check the error type returned instead of string matching; we could still check if the error contains the image name (to double check the cause is indeed because of the image), but checking for the kind of error may be more relevant than the error message; similar to

assert.ErrorType(t, err, cerrdefs.IsNotFound)

@robmry
Copy link
Contributor

robmry commented Nov 13, 2025

Thank you for the update @2003Aditya ... please could you squash and force-push the commits, to make a single commit? (It'll be something like "git rebase -i master", and set the second commit to "s". Then "git push --force" to replace the existing commits.)

It'd be good to pick up @thaJeztah's suggestion of checking the error types at the same time?

Comment on lines +189 to +190
fakecontext.WithDockerfile(`FROM busybox
ENV FOO bar`))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure if whitespace at the start of the line in the Dockerfile would work - so tried it, and it was ok. But I got this warning, also worth fixing ..

 1 warning found (use docker --debug to expand):
 - LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format (line 2)

@2003Aditya 2003Aditya force-pushed the TestAPIImagesDelete branch 2 times, most recently from d4c75fc to 5c1115c Compare November 13, 2025 11:30
Comment on lines +206 to +210
_, err = apiClient.ImageRemove(ctx, imgID, client.ImageRemoveOptions{})
assert.Check(t, is.ErrorContains(err, "unable to delete"))

_, err = apiClient.ImageRemove(ctx, "test:noexist", client.ImageRemoveOptions{})
assert.ErrorType(t, err, cerrdefs.IsNotFound)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @2003Aditya - to implement the suggestion "to check the error type returned instead of string matching; we could still check if the error contains the image name (to double check the cause is indeed because of the image)" ... would need an error-type and a string check for both errors.

So, also using assert.Check so later checks still run if one fails, it'd be ...

Suggested change
_, err = apiClient.ImageRemove(ctx, imgID, client.ImageRemoveOptions{})
assert.Check(t, is.ErrorContains(err, "unable to delete"))
_, err = apiClient.ImageRemove(ctx, "test:noexist", client.ImageRemoveOptions{})
assert.ErrorType(t, err, cerrdefs.IsNotFound)
_, err = apiClient.ImageRemove(ctx, imgID, client.ImageRemoveOptions{})
assert.Check(t, is.ErrorType(err, cerrdefs.IsConflict))
assert.Check(t, is.ErrorContains(err, "unable to delete "+stringid.TruncateID(imgID)))
_, err = apiClient.ImageRemove(ctx, "test:noexist", client.ImageRemoveOptions{})
assert.Check(t, is.ErrorType(err, cerrdefs.IsNotFound))
assert.Check(t, is.ErrorContains(err, "No such image: test:noexist"))

… 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>
Copy link
Contributor

@robmry robmry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - thank you.

The TestBuildWithHugeFile timeout/failure is unrelated (the test would be skipped if rebased).

@robmry robmry requested a review from thaJeztah November 16, 2025 14:10
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thaJeztah thaJeztah added this to the 29.1.0 milestone Nov 16, 2025
@thaJeztah thaJeztah merged commit cf7cc93 into moby:master Nov 16, 2025
246 of 250 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/images Image Distribution area/testing kind/refactor PR's that refactor, or clean-up code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants