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>
31 lines
922 B
Go
31 lines
922 B
Go
package image
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/docker/docker/api/types/filters"
|
|
"github.com/docker/docker/integration/internal/container"
|
|
"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/45732
|
|
func TestPruneDontDeleteUsedDangling(t *testing.T) {
|
|
skip.If(t, testEnv.DaemonInfo.OSType == "windows", "FIXME: hack/make/.build-empty-images doesn't run on Windows")
|
|
|
|
ctx := setupTest(t)
|
|
client := testEnv.APIClient()
|
|
|
|
danglingID := specialimage.Load(ctx, t, client, specialimage.Dangling)
|
|
|
|
container.Create(ctx, t, client,
|
|
container.WithImage(danglingID),
|
|
container.WithCmd("sleep", "60"))
|
|
|
|
pruned, err := client.ImagesPrune(ctx, filters.NewArgs(filters.Arg("dangling", "true")))
|
|
|
|
assert.NilError(t, err)
|
|
assert.Check(t, is.Len(pruned.ImagesDeleted, 0))
|
|
}
|