2014-02-11 23:04:39 -05:00
|
|
|
package runconfig
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2014-05-02 04:47:12 -04:00
|
|
|
|
|
|
|
"github.com/dotcloud/docker/utils"
|
2014-02-11 23:04:39 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestParseLxcConfOpt(t *testing.T) {
|
|
|
|
opts := []string{"lxc.utsname=docker", "lxc.utsname = docker "}
|
|
|
|
|
|
|
|
for _, o := range opts {
|
2014-03-13 12:03:09 -04:00
|
|
|
k, v, err := utils.ParseKeyValueOpt(o)
|
2014-02-11 23:04:39 -05:00
|
|
|
if err != nil {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
|
|
|
if k != "lxc.utsname" {
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
if v != "docker" {
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-06-11 17:15:48 -04:00
|
|
|
|
|
|
|
func TestNetHostname(t *testing.T) {
|
|
|
|
if _, _, _, err := Parse([]string{"-h=name", "img", "cmd"}, nil); err != nil {
|
2014-06-21 04:32:39 -04:00
|
|
|
t.Fatalf("Unexpected error: %s", err)
|
2014-06-11 17:15:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if _, _, _, err := Parse([]string{"--net=host", "img", "cmd"}, nil); err != nil {
|
2014-06-21 04:32:39 -04:00
|
|
|
t.Fatalf("Unexpected error: %s", err)
|
2014-06-11 17:15:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if _, _, _, err := Parse([]string{"-h=name", "--net=bridge", "img", "cmd"}, nil); err != nil {
|
2014-06-21 04:32:39 -04:00
|
|
|
t.Fatalf("Unexpected error: %s", err)
|
2014-06-11 17:15:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if _, _, _, err := Parse([]string{"-h=name", "--net=none", "img", "cmd"}, nil); err != nil {
|
2014-06-21 04:32:39 -04:00
|
|
|
t.Fatalf("Unexpected error: %s", err)
|
2014-06-11 17:15:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if _, _, _, err := Parse([]string{"-h=name", "--net=host", "img", "cmd"}, nil); err != ErrConflictNetworkHostname {
|
2014-06-21 04:32:39 -04:00
|
|
|
t.Fatalf("Expected error ErrConflictNetworkHostname, got: %s", err)
|
2014-06-11 17:15:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if _, _, _, err := Parse([]string{"-h=name", "--net=container:other", "img", "cmd"}, nil); err != ErrConflictNetworkHostname {
|
2014-06-21 04:32:39 -04:00
|
|
|
t.Fatalf("Expected error ErrConflictNetworkHostname, got: %s", err)
|
2014-06-11 17:15:48 -04:00
|
|
|
}
|
|
|
|
}
|