1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/runconfig/parse_test.go
Kato Kazuyoshi 00469957ad Fatal() doesn't take a format string like Fatalf()
Docker-DCO-1.1-Signed-off-by: Kato Kazuyoshi <kato.kazuyoshi@gmail.com> (github: kzys)
2014-06-21 17:32:39 +09:00

50 lines
1.3 KiB
Go

package runconfig
import (
"testing"
"github.com/dotcloud/docker/utils"
)
func TestParseLxcConfOpt(t *testing.T) {
opts := []string{"lxc.utsname=docker", "lxc.utsname = docker "}
for _, o := range opts {
k, v, err := utils.ParseKeyValueOpt(o)
if err != nil {
t.FailNow()
}
if k != "lxc.utsname" {
t.Fail()
}
if v != "docker" {
t.Fail()
}
}
}
func TestNetHostname(t *testing.T) {
if _, _, _, err := Parse([]string{"-h=name", "img", "cmd"}, nil); err != nil {
t.Fatalf("Unexpected error: %s", err)
}
if _, _, _, err := Parse([]string{"--net=host", "img", "cmd"}, nil); err != nil {
t.Fatalf("Unexpected error: %s", err)
}
if _, _, _, err := Parse([]string{"-h=name", "--net=bridge", "img", "cmd"}, nil); err != nil {
t.Fatalf("Unexpected error: %s", err)
}
if _, _, _, err := Parse([]string{"-h=name", "--net=none", "img", "cmd"}, nil); err != nil {
t.Fatalf("Unexpected error: %s", err)
}
if _, _, _, err := Parse([]string{"-h=name", "--net=host", "img", "cmd"}, nil); err != ErrConflictNetworkHostname {
t.Fatalf("Expected error ErrConflictNetworkHostname, got: %s", err)
}
if _, _, _, err := Parse([]string{"-h=name", "--net=container:other", "img", "cmd"}, nil); err != ErrConflictNetworkHostname {
t.Fatalf("Expected error ErrConflictNetworkHostname, got: %s", err)
}
}