1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/runconfig/config_test.go
John Howard a7e686a779 Windows: Add volume support
Signed-off-by: John Howard <jhoward@microsoft.com>
2015-10-22 10:42:53 -07:00

62 lines
1.3 KiB
Go

package runconfig
import (
"bytes"
"fmt"
"io/ioutil"
"runtime"
"testing"
"github.com/docker/docker/pkg/stringutils"
)
type f struct {
file string
entrypoint *stringutils.StrSlice
}
func TestDecodeContainerConfig(t *testing.T) {
var (
fixtures []f
image string
)
if runtime.GOOS != "windows" {
image = "ubuntu"
fixtures = []f{
{"fixtures/unix/container_config_1_14.json", stringutils.NewStrSlice()},
{"fixtures/unix/container_config_1_17.json", stringutils.NewStrSlice("bash")},
{"fixtures/unix/container_config_1_19.json", stringutils.NewStrSlice("bash")},
}
} else {
image = "windows"
fixtures = []f{
{"fixtures/windows/container_config_1_19.json", stringutils.NewStrSlice("cmd")},
}
}
for _, f := range fixtures {
b, err := ioutil.ReadFile(f.file)
if err != nil {
t.Fatal(err)
}
c, h, err := DecodeContainerConfig(bytes.NewReader(b))
if err != nil {
t.Fatal(fmt.Errorf("Error parsing %s: %v", f, err))
}
if c.Image != image {
t.Fatalf("Expected %s image, found %s\n", image, c.Image)
}
if c.Entrypoint.Len() != f.entrypoint.Len() {
t.Fatalf("Expected %v, found %v\n", f.entrypoint, c.Entrypoint)
}
if h != nil && h.Memory != 1000 {
t.Fatalf("Expected memory to be 1000, found %d\n", h.Memory)
}
}
}