1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
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.Fatal("Unexpected error: %s", err)
}
if _, _, _, err := Parse([]string{"--net=host", "img", "cmd"}, nil); err != nil {
t.Fatal("Unexpected error: %s", err)
}
if _, _, _, err := Parse([]string{"-h=name", "--net=bridge", "img", "cmd"}, nil); err != nil {
t.Fatal("Unexpected error: %s", err)
}
if _, _, _, err := Parse([]string{"-h=name", "--net=none", "img", "cmd"}, nil); err != nil {
t.Fatal("Unexpected error: %s", err)
}
if _, _, _, err := Parse([]string{"-h=name", "--net=host", "img", "cmd"}, nil); err != ErrConflictNetworkHostname {
t.Fatal("Expected error ErrConflictNetworkHostname, got: %s", err)
}
if _, _, _, err := Parse([]string{"-h=name", "--net=container:other", "img", "cmd"}, nil); err != ErrConflictNetworkHostname {
t.Fatal("Expected error ErrConflictNetworkHostname, got: %s", err)
}
}
|