github.com/rawahars/moby@v24.0.4+incompatible/integration/image/inspect_test.go (about) 1 package image 2 3 import ( 4 "context" 5 "encoding/json" 6 "testing" 7 8 "github.com/docker/docker/testutil/environment" 9 "gotest.tools/v3/assert" 10 is "gotest.tools/v3/assert/cmp" 11 "gotest.tools/v3/skip" 12 ) 13 14 // Regression test for: https://github.com/moby/moby/issues/45556 15 func TestImageInspectEmptyTagsAndDigests(t *testing.T) { 16 skip.If(t, testEnv.OSType == "windows", "build-empty-images is not called on Windows") 17 defer setupTest(t)() 18 19 client := testEnv.APIClient() 20 ctx := context.Background() 21 22 danglingID := environment.GetTestDanglingImageId(testEnv) 23 24 inspect, raw, err := client.ImageInspectWithRaw(ctx, danglingID) 25 assert.NilError(t, err) 26 27 // Must be a zero length array, not null. 28 assert.Check(t, is.Len(inspect.RepoTags, 0)) 29 assert.Check(t, is.Len(inspect.RepoDigests, 0)) 30 31 var rawJson map[string]interface{} 32 err = json.Unmarshal(raw, &rawJson) 33 assert.NilError(t, err) 34 35 // Check if the raw json is also an array, not null. 36 assert.Check(t, is.Len(rawJson["RepoTags"], 0)) 37 assert.Check(t, is.Len(rawJson["RepoDigests"], 0)) 38 }