2014-02-11 23:04:39 -05:00
|
|
|
package runconfig
|
2013-11-14 01:08:08 -05:00
|
|
|
|
|
|
|
import (
|
2015-04-10 20:05:21 -04:00
|
|
|
"bytes"
|
2014-06-25 18:46:41 -04:00
|
|
|
"fmt"
|
2015-04-10 20:05:21 -04:00
|
|
|
"io/ioutil"
|
2013-11-14 01:08:08 -05:00
|
|
|
"testing"
|
|
|
|
|
2015-08-28 11:29:10 -04:00
|
|
|
"github.com/docker/docker/pkg/stringutils"
|
|
|
|
)
|
2015-04-10 20:05:21 -04:00
|
|
|
|
|
|
|
func TestDecodeContainerConfig(t *testing.T) {
|
|
|
|
fixtures := []struct {
|
|
|
|
file string
|
2015-08-28 11:29:10 -04:00
|
|
|
entrypoint *stringutils.StrSlice
|
2015-04-10 20:05:21 -04:00
|
|
|
}{
|
2015-08-28 11:29:10 -04:00
|
|
|
{"fixtures/container_config_1_14.json", stringutils.NewStrSlice()},
|
|
|
|
{"fixtures/container_config_1_17.json", stringutils.NewStrSlice("bash")},
|
|
|
|
{"fixtures/container_config_1_19.json", stringutils.NewStrSlice("bash")},
|
2015-04-10 20:05:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
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))
|
|
|
|
}
|
2013-11-14 01:08:08 -05:00
|
|
|
|
2015-04-10 20:05:21 -04:00
|
|
|
if c.Image != "ubuntu" {
|
|
|
|
t.Fatalf("Expected ubuntu image, found %s\n", c.Image)
|
|
|
|
}
|
|
|
|
|
|
|
|
if c.Entrypoint.Len() != f.entrypoint.Len() {
|
|
|
|
t.Fatalf("Expected %v, found %v\n", f.entrypoint, c.Entrypoint)
|
|
|
|
}
|
|
|
|
|
|
|
|
if h.Memory != 1000 {
|
|
|
|
t.Fatalf("Expected memory to be 1000, found %d\n", h.Memory)
|
|
|
|
}
|
|
|
|
}
|
2013-11-14 01:08:08 -05:00
|
|
|
}
|