From aebe8e8ce7dcd77a50cc1fb2c4ce71dca375651a Mon Sep 17 00:00:00 2001 From: chchliang Date: Mon, 18 Sep 2017 09:58:08 +0800 Subject: [PATCH] add Images testcase Signed-off-by: chchliang Upstream-commit: 832f39c2ed53fc4a91265798198273044448bc7f Component: engine --- components/engine/image/image_test.go | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/components/engine/image/image_test.go b/components/engine/image/image_test.go index e04587edae..899666a60e 100644 --- a/components/engine/image/image_test.go +++ b/components/engine/image/image_test.go @@ -2,6 +2,7 @@ package image import ( "encoding/json" + "runtime" "sort" "strings" "testing" @@ -54,6 +55,39 @@ func TestMarshalKeyOrder(t *testing.T) { } } +func TestImage(t *testing.T) { + cid := "50a16564e727" + config := &container.Config{ + Hostname: "hostname", + Domainname: "domain", + User: "root", + } + platform := runtime.GOOS + + img := &Image{ + V1Image: V1Image{ + Config: config, + }, + computedID: ID(cid), + } + + assert.Equal(t, cid, img.ImageID()) + assert.Equal(t, cid, img.ID().String()) + assert.Equal(t, platform, img.Platform()) + assert.Equal(t, config, img.RunConfig()) +} + +func TestImagePlatformNotEmpty(t *testing.T) { + platform := "platform" + img := &Image{ + V1Image: V1Image{ + OS: platform, + }, + OSVersion: "osversion", + } + assert.Equal(t, platform, img.Platform()) +} + func TestNewChildImageFromImageWithRootFS(t *testing.T) { rootFS := NewRootFS() rootFS.Append(layer.DiffID("ba5e"))