diff --git a/cmd/nerdctl/image/image_inspect_test.go b/cmd/nerdctl/image/image_inspect_test.go index 95154304d1c..66065e1813f 100644 --- a/cmd/nerdctl/image/image_inspect_test.go +++ b/cmd/nerdctl/image/image_inspect_test.go @@ -18,7 +18,6 @@ package image import ( "encoding/json" - "runtime" "strings" "testing" @@ -71,18 +70,15 @@ func TestImageInspectSimpleCases(t *testing.T) { func TestImageInspectDifferentValidReferencesForTheSameImage(t *testing.T) { nerdtest.Setup() - platform := runtime.GOOS + "/" + runtime.GOARCH - tags := []string{ "", ":latest", ":stable", } names := []string{ - "busybox", - "library/busybox", - "docker.io/library/busybox", - "registry-1.docker.io/library/busybox", + "apostasie/busybox", + "docker.io/apostasie/busybox", + "registry-1.docker.io/apostasie/busybox", } testCase := &test.Case{ @@ -94,16 +90,16 @@ func TestImageInspectDifferentValidReferencesForTheSameImage(t *testing.T) { nerdtest.Private, ), Setup: func(data test.Data, helpers test.Helpers) { - helpers.Ensure("pull", "alpine", "--platform", platform) - helpers.Ensure("pull", "busybox", "--platform", platform) - helpers.Ensure("pull", "busybox:stable", "--platform", platform) - helpers.Ensure("pull", "registry-1.docker.io/library/busybox", "--platform", platform) - helpers.Ensure("pull", "registry-1.docker.io/library/busybox:stable", "--platform", platform) + helpers.Ensure("pull", "alpine") + helpers.Ensure("pull", "apostasie/busybox") + helpers.Ensure("pull", "apostasie/busybox:stable") + helpers.Ensure("pull", "registry-1.docker.io/apostasie/busybox") + helpers.Ensure("pull", "registry-1.docker.io/apostasie/busybox:stable") }, SubTests: []*test.Case{ { Description: "name and tags +/- sha combinations", - Command: test.RunCommand("image", "inspect", "busybox"), + Command: test.RunCommand("image", "inspect", "apostasie/busybox"), Expected: func(data test.Data, helpers test.Helpers) *test.Expected { return &test.Expected{ Output: func(stdout string, info string, t *testing.T) { @@ -112,7 +108,7 @@ func TestImageInspectDifferentValidReferencesForTheSameImage(t *testing.T) { assert.NilError(t, err, "Unable to unmarshal output\n"+info) assert.Equal(t, 1, len(dc), "Unexpectedly got multiple results\n"+info) reference := dc[0].ID - sha := strings.TrimPrefix(dc[0].RepoDigests[0], "busybox@sha256:") + sha := strings.TrimPrefix(dc[0].RepoDigests[0], "apostasie/busybox@sha256:") for _, name := range names { for _, tag := range tags { @@ -128,7 +124,7 @@ func TestImageInspectDifferentValidReferencesForTheSameImage(t *testing.T) { }, { Description: "by digest, short or long, with or without prefix", - Command: test.RunCommand("image", "inspect", "busybox"), + Command: test.RunCommand("image", "inspect", "apostasie/busybox"), Expected: func(data test.Data, helpers test.Helpers) *test.Expected { return &test.Expected{ Output: func(stdout string, info string, t *testing.T) { @@ -137,7 +133,7 @@ func TestImageInspectDifferentValidReferencesForTheSameImage(t *testing.T) { assert.NilError(t, err, "Unable to unmarshal output\n"+info) assert.Equal(t, 1, len(dc), "Unexpectedly got multiple results\n"+info) reference := dc[0].ID - sha := strings.TrimPrefix(dc[0].RepoDigests[0], "busybox@sha256:") + sha := strings.TrimPrefix(dc[0].RepoDigests[0], "apostasie/busybox@sha256:") for _, id := range []string{"sha256:" + sha, sha, sha[0:8], "sha256:" + sha[0:8]} { it := nerdtest.InspectImage(helpers, id) @@ -159,7 +155,7 @@ func TestImageInspectDifferentValidReferencesForTheSameImage(t *testing.T) { }, { Description: "prove that wrong references with correct digest do not get resolved", - Command: test.RunCommand("image", "inspect", "busybox"), + Command: test.RunCommand("image", "inspect", "apostasie/busybox"), Expected: func(data test.Data, helpers test.Helpers) *test.Expected { return &test.Expected{ Output: func(stdout string, info string, t *testing.T) { @@ -167,9 +163,9 @@ func TestImageInspectDifferentValidReferencesForTheSameImage(t *testing.T) { err := json.Unmarshal([]byte(stdout), &dc) assert.NilError(t, err, "Unable to unmarshal output\n"+info) assert.Equal(t, 1, len(dc), "Unexpectedly got multiple results\n"+info) - sha := strings.TrimPrefix(dc[0].RepoDigests[0], "busybox@sha256:") + sha := strings.TrimPrefix(dc[0].RepoDigests[0], "apostasie/busybox@sha256:") - for _, id := range []string{"doesnotexist", "doesnotexist:either", "busybox:bogustag"} { + for _, id := range []string{"doesnotexist", "doesnotexist:either", "apostasie/busybox:bogustag"} { cmd := helpers.Command("image", "inspect", id+"@sha256:"+sha) cmd.Run(&test.Expected{ Output: test.Equals(""), @@ -181,7 +177,7 @@ func TestImageInspectDifferentValidReferencesForTheSameImage(t *testing.T) { }, { Description: "prove that invalid reference return no result without crashing", - Command: test.RunCommand("image", "inspect", "busybox"), + Command: test.RunCommand("image", "inspect", "apostasie/busybox"), Expected: func(data test.Data, helpers test.Helpers) *test.Expected { return &test.Expected{ Output: func(stdout string, info string, t *testing.T) { @@ -202,7 +198,7 @@ func TestImageInspectDifferentValidReferencesForTheSameImage(t *testing.T) { }, { Description: "retrieving multiple entries at once", - Command: test.RunCommand("image", "inspect", "busybox", "busybox", "busybox:stable"), + Command: test.RunCommand("image", "inspect", "apostasie/busybox", "apostasie/busybox", "apostasie/busybox:stable"), Expected: func(data test.Data, helpers test.Helpers) *test.Expected { return &test.Expected{ Output: func(stdout string, info string, t *testing.T) { @@ -210,7 +206,7 @@ func TestImageInspectDifferentValidReferencesForTheSameImage(t *testing.T) { err := json.Unmarshal([]byte(stdout), &dc) assert.NilError(t, err, "Unable to unmarshal output\n"+info) assert.Equal(t, 3, len(dc), "Unexpectedly did not get 3 results\n"+info) - reference := nerdtest.InspectImage(helpers, "busybox") + reference := nerdtest.InspectImage(helpers, "apostasie/busybox") assert.Equal(t, dc[0].ID, reference.ID) assert.Equal(t, dc[1].ID, reference.ID) assert.Equal(t, dc[2].ID, reference.ID)