Skip to content

integration: migrate TestInspectAPIImageResponse to integration suite - #52722

Merged
vvoland merged 1 commit into
moby:masterfrom
notandruu:integration/migrate-TestInspectAPIImageResponse
Jun 18, 2026
Merged

vvoland merged 1 commit into
moby:masterfrom
notandruu:integration/migrate-TestInspectAPIImageResponse

Conversation

@notandruu

@notandruu notandruu commented May 29, 2026 •

Copy link
Copy Markdown
Contributor

Migrates TestInspectAPIImageResponse from integration-cli to the new
integration test suite, as part of the ongoing effort to replace CLI-based tests
with API-based tests (#50159).

Summary

Move TestInspectAPIImageResponse from integration-cli/docker_api_inspect_test.go
to integration/image/inspect_test.go as TestImageInspectRepoTags. The new test:

  • Uses testEnv.APIClient() and the typed Go client instead of CLI wrappers
  • Uses t.Cleanup instead of defer for cleanup registration
  • Uses a test-name-derived unique tag to avoid conflicts with parallel tests

The original test function and its unused imports are removed from integration-cli.

Release notes (optional)

A picture of a cute animal (not mandatory but encouraged)

Created with: Claude Code

Comment thread integration/image/inspect_test.go Outdated

_, err := apiClient.ImageTag(ctx, client.ImageTagOptions{Source: "busybox:latest", Target: "busybox:testtag"})
assert.NilError(t, err)
defer func() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

  • Perhaps t.Cleanup( instead of defer
  • Wondering if we should use a unique tag instead of testtag, just in case the same tag is used in another test (possibly could use t.Name() as name for the tag)

@thaJeztah

Copy link
Copy Markdown
Member

Thanks for updating; before I restart CI; could you squash the commits?

@notandruu
notandruu force-pushed the integration/migrate-TestInspectAPIImageResponse branch from 0567859 to a99186b Compare May 29, 2026 12:13
@notandruu

Copy link
Copy Markdown
Contributor Author

The inline suggestions (t.Cleanup and t.Name()-based unique tag) are already in the current version — both were incorporated before vvoland's approval. The shfmt failure appears to be pre-existing and not introduced by this PR (no shell files changed). Ready for another look when you have a moment.

"github.com/moby/moby/v2/integration-cli/cli"
"github.com/moby/moby/v2/internal/testutil"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks like this import is no longer used, which causes CI to fail;

=== Errors
Error: integration-cli\docker_api_inspect_test.go:11:2: "gotest.tools/v3/assert/cmp" imported as is and not used

@notandruu
notandruu force-pushed the integration/migrate-TestInspectAPIImageResponse branch from a99186b to a1aa0ae Compare June 1, 2026 14:36
@notandruu

Copy link
Copy Markdown
Contributor Author

Hi @thaJeztah — the commits are now squashed to a single one. Ready for CI restart when you get a chance.

@notandruu
notandruu force-pushed the integration/migrate-TestInspectAPIImageResponse branch from a1aa0ae to 9f5b814 Compare June 9, 2026 18:32
@notandruu

Copy link
Copy Markdown
Contributor Author

Rebased on current master to retrigger CI.

Both review comments are addressed in the current revision: the test now uses t.Cleanup and a unique tag derived from t.Name(), and the unused cmp import in integration-cli/docker_api_inspect_test.go is gone (both packages vet clean for linux/amd64).

The previous run's failures looked unrelated to this change: cross (linux/arm/v7) was a runner shutdown, and the test-windows ./client shards don't touch anything in this diff.

@thaJeztah PTAL when you get a chance.

Comment thread integration/image/inspect_test.go Outdated
Comment on lines +284 to +286
t.Cleanup(func() {
_, _ = apiClient.ImageRemove(ctx, tag, client.ImageRemoveOptions{Force: true})
})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Actually just realised that this cleanup is not needed at all; setupTest should already take care of that;

func setupTest(t *testing.T) context.Context {
ctx := testutil.StartSpan(baseContext, t)
environment.ProtectAll(ctx, t, testEnv)
t.Cleanup(func() { testEnv.Clean(ctx, t) })
return ctx
}

let me do a quick rebase and remove this

@thaJeztah
thaJeztah force-pushed the integration/migrate-TestInspectAPIImageResponse branch from 9f5b814 to 9f3eb30 Compare June 18, 2026 00:09
@thaJeztah thaJeztah added this to the 29.6.0 milestone Jun 18, 2026

@thaJeztah thaJeztah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks!

Comment thread integration/image/inspect_test.go Outdated
Comment on lines +274 to +276
// TestImageInspectRepoTags verifies that ImageInspect returns the correct
// RepoTags after an image has been tagged. Migrated from integration-cli
// TestInspectAPIImageResponse.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's remove this bit; I'll fix before merging (waiting for CI to finish)

Suggested change
// TestImageInspectRepoTags verifies that ImageInspect returns the correct
// RepoTags after an image has been tagged. Migrated from integration-cli
// TestInspectAPIImageResponse.
// TestImageInspectRepoTags verifies that ImageInspect returns the correct
// RepoTags after an image has been tagged.

@thaJeztah
thaJeztah force-pushed the integration/migrate-TestInspectAPIImageResponse branch from 9f3eb30 to 1567f9e Compare June 18, 2026 11:28
@vvoland
vvoland merged commit 3b2f557 into moby:master Jun 18, 2026
55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants