github.com/Prakhar-Agarwal-byte/moby@v0.0.0-20231027092010-a14e3e8ab87e/integration/image/inspect_test.go (about)

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