From f6b3b257c828835f4a3bca5b9eb95edcf76e8946 Mon Sep 17 00:00:00 2001 From: Abubacarr Ceesay Date: Fri, 11 Jul 2025 19:04:37 +0200 Subject: [PATCH] implement test api images history integration test on dedicated file Signed-off-by: Abubacarr Ceesay --- integration/image/history_test.go | 33 +++++++++++++++++++++++++++++++ integration/image/list_test.go | 28 -------------------------- 2 files changed, 33 insertions(+), 28 deletions(-) create mode 100644 integration/image/history_test.go diff --git a/integration/image/history_test.go b/integration/image/history_test.go new file mode 100644 index 0000000000..9dd7ebf3bf --- /dev/null +++ b/integration/image/history_test.go @@ -0,0 +1,33 @@ +package image + +import ( + "testing" + + "github.com/docker/docker/integration/internal/build" + "github.com/docker/docker/testutil/fakecontext" + "gotest.tools/v3/assert" +) + +func TestAPIImagesHistory(t *testing.T) { + ctx := setupTest(t) + client := testEnv.APIClient() + + dockerfile := "FROM busybox\nENV FOO bar" + + imgID := build.Do(ctx, t, client, fakecontext.New(t, t.TempDir(), fakecontext.WithDockerfile(dockerfile))) + + historydata, err := client.ImageHistory(ctx, imgID) + assert.NilError(t, err) + + assert.Assert(t, len(historydata) != 0) + + var found bool + for _, imageLayer := range historydata { + if imageLayer.ID == imgID { + found = true + break + } + } + + assert.Assert(t, found) +} diff --git a/integration/image/list_test.go b/integration/image/list_test.go index 5720329efc..35622aed61 100644 --- a/integration/image/list_test.go +++ b/integration/image/list_test.go @@ -13,12 +13,10 @@ import ( "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/versions" "github.com/docker/docker/client" - buildImage "github.com/docker/docker/integration/internal/build" "github.com/docker/docker/integration/internal/container" "github.com/docker/docker/internal/testutils/specialimage" "github.com/docker/docker/testutil" "github.com/docker/docker/testutil/daemon" - "github.com/docker/docker/testutil/fakecontext" "github.com/google/go-cmp/cmp/cmpopts" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "gotest.tools/v3/assert" @@ -315,29 +313,3 @@ func TestAPIImagesListManifests(t *testing.T) { } } } - -func TestAPIImagesHistory(t *testing.T) { - ctx := setupTest(t) - - client := testEnv.APIClient() - - dockerfile := "FROM busybox\nENV FOO bar" - - imgID := buildImage.Do(ctx, t, client, fakecontext.New(t, t.TempDir(), fakecontext.WithDockerfile(dockerfile))) - - historydata, err := client.ImageHistory(ctx, imgID) - - assert.NilError(t, err) - - assert.Assert(t, len(historydata) != 0) - - var found bool - for _, imageLayer := range historydata { - if imageLayer.ID == imgID { - found = true - break - } - } - - assert.Assert(t, found) -}