Browse Source

add tests

Docker-DCO-1.1-Signed-off-by: Victor Vieux <vieux@docker.com> (github: vieux)
Victor Vieux 11 years ago
parent
commit
6cb16f1c31
1 changed files with 26 additions and 0 deletions
  1. 26 0
      runconfig/parse_test.go

+ 26 - 0
runconfig/parse_test.go

@@ -22,3 +22,29 @@ func TestParseLxcConfOpt(t *testing.T) {
 		}
 		}
 	}
 	}
 }
 }
+
+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)
+	}
+}