add Images testcase

Signed-off-by: chchliang <chen.chuanliang@zte.com.cn>
This commit is contained in:
chchliang 2017-09-18 09:58:08 +08:00
parent 48cce22933
commit 832f39c2ed

View file

@ -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"))