Browse code

integration: migrate TestInspectAPIImageResponse to integration suite

Signed-off-by: Andrew Liu <andrewjliu22@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Andrew Liu authored on 2026/05/29 21:13:38
Showing 2 changed files
... ...
@@ -6,11 +6,8 @@ import (
6 6
 	"testing"
7 7
 
8 8
 	"github.com/moby/moby/api/types/container"
9
-	"github.com/moby/moby/client"
10 9
 	"github.com/moby/moby/v2/integration-cli/cli"
11
-	"github.com/moby/moby/v2/internal/testutil"
12 10
 	"gotest.tools/v3/assert"
13
-	is "gotest.tools/v3/assert/cmp"
14 11
 )
15 12
 
16 13
 func (s *DockerAPISuite) TestInspectAPIContainerResponse(c *testing.T) {
... ...
@@ -70,20 +67,6 @@ func (s *DockerAPISuite) TestInspectAPIContainerVolumeDriver(c *testing.T) {
70 70
 	assert.Assert(c, ok, "API version 1.25 expected to include VolumeDriver in 'HostConfig'")
71 71
 }
72 72
 
73
-func (s *DockerAPISuite) TestInspectAPIImageResponse(c *testing.T) {
74
-	cli.DockerCmd(c, "tag", "busybox:latest", "busybox:mytag")
75
-	apiClient, err := client.New(client.FromEnv)
76
-	assert.NilError(c, err)
77
-	defer apiClient.Close()
78
-
79
-	imageJSON, err := apiClient.ImageInspect(testutil.GetContext(c), "busybox")
80
-	assert.NilError(c, err)
81
-
82
-	assert.Check(c, len(imageJSON.RepoTags) == 2)
83
-	assert.Check(c, is.Contains(imageJSON.RepoTags, "busybox:latest"))
84
-	assert.Check(c, is.Contains(imageJSON.RepoTags, "busybox:mytag"))
85
-}
86
-
87 73
 // Inspect for API v1.21 and up; see
88 74
 //
89 75
 // - https://github.com/moby/moby/issues/17131
... ...
@@ -3,6 +3,7 @@ package image
3 3
 import (
4 4
 	"bytes"
5 5
 	"encoding/json"
6
+	"strings"
6 7
 	"testing"
7 8
 
8 9
 	"github.com/moby/moby/client"
... ...
@@ -269,3 +270,20 @@ func TestImageInspectWithPlatform(t *testing.T) {
269 269
 		})
270 270
 	}
271 271
 }
272
+
273
+// TestImageInspectRepoTags verifies that ImageInspect returns the correct
274
+// RepoTags after an image has been tagged.
275
+func TestImageInspectRepoTags(t *testing.T) {
276
+	ctx := setupTest(t)
277
+	apiClient := testEnv.APIClient()
278
+
279
+	tag := "busybox:" + strings.ReplaceAll(t.Name(), "/", "-")
280
+	_, err := apiClient.ImageTag(ctx, client.ImageTagOptions{Source: "busybox:latest", Target: tag})
281
+	assert.NilError(t, err)
282
+
283
+	imageJSON, err := apiClient.ImageInspect(ctx, "busybox")
284
+	assert.NilError(t, err)
285
+
286
+	assert.Check(t, is.Contains(imageJSON.RepoTags, "busybox:latest"))
287
+	assert.Check(t, is.Contains(imageJSON.RepoTags, tag))
288
+}