bc94dfc7d2
Rewrite `.build-empty-images` shell script that produced special images (emptyfs with no layers, and empty danglign image) to a Go functions that construct the same archives in a temporary directory. Use them to load these images on demand only in the tests that need them. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
36 lines
1 KiB
Go
36 lines
1 KiB
Go
package image
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"github.com/docker/docker/internal/testutils/specialimage"
|
|
"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.DaemonInfo.OSType == "windows", "build-empty-images is not called on Windows")
|
|
ctx := setupTest(t)
|
|
|
|
client := testEnv.APIClient()
|
|
|
|
danglingID := specialimage.Load(ctx, t, client, specialimage.Dangling)
|
|
|
|
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))
|
|
}
|