mirror of
https://github.com/moby/moby.git
synced 2026-08-03 14:41:03 +00:00
implement test api images history integration test on dedicated file
Signed-off-by: Abubacarr Ceesay <abubacarr671@gmail.com>
This commit is contained in:
33
integration/image/history_test.go
Normal file
33
integration/image/history_test.go
Normal file
@@ -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)
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user