-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
integration: Add TestImageInspectEmptyTagsAndDigests
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
- Loading branch information
Showing
4 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package image | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"testing" | ||
|
||
"github.com/docker/docker/testutil/environment" | ||
"gotest.tools/v3/assert" | ||
is "gotest.tools/v3/assert/cmp" | ||
"gotest.tools/v3/skip" | ||
) | ||
|
||
// Regression test for: https://github.com/moby/moby/issues/45556 | ||
func TestImageInspectEmptyTagsAndDigests(t *testing.T) { | ||
skip.If(t, testEnv.OSType == "windows", "build-empty-images is not called on Windows") | ||
defer setupTest(t)() | ||
|
||
client := testEnv.APIClient() | ||
ctx := context.Background() | ||
|
||
danglingId := environment.DanglingImageIdGraphDriver | ||
if testEnv.UsingSnapshotter() { | ||
danglingId = environment.DanglingImageIdSnapshotter | ||
} | ||
|
||
inspect, raw, err := client.ImageInspectWithRaw(ctx, danglingId) | ||
assert.NilError(t, err) | ||
|
||
// Must be a zero length array, not null. | ||
assert.Check(t, is.Len(inspect.RepoTags, 0)) | ||
assert.Check(t, is.Len(inspect.RepoDigests, 0)) | ||
|
||
var rawJson map[string]interface{} | ||
err = json.Unmarshal(raw, &rawJson) | ||
assert.NilError(t, err) | ||
|
||
// Check if the raw json is also an array, not null. | ||
assert.Check(t, is.Len(rawJson["RepoTags"], 0)) | ||
assert.Check(t, is.Len(rawJson["RepoDigests"], 0)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package environment | ||
|
||
// Graph driver image store identifies images by the ID of their config. | ||
const DanglingImageIdGraphDriver = "sha256:0df1207206e5288f4a989a2f13d1f5b3c4e70467702c1d5d21dfc9f002b7bd43" | ||
|
||
// The containerd image store identifies images by the ID of their manifest/manifest list. | ||
const DanglingImageIdSnapshotter = "sha256:16d365089e5c10e1673ee82ab5bba38ade9b763296ad918bd24b42a1156c5456" |