Browse code

add tests

Victor Vieux authored on 2013/06/19 21:40:01
Showing 1 changed files
... ...
@@ -274,3 +274,21 @@ func TestHumanSize(t *testing.T) {
274 274
 		t.Errorf("1024 -> expected 1.024 kB, got %s", size1024)
275 275
 	}
276 276
 }
277
+
278
+func TestParseHost(t *testing.T) {
279
+	if addr := ParseHost("127.0.0.1", 4243, "0.0.0.0"); addr != "tcp://0.0.0.0:4243" {
280
+		t.Errorf("0.0.0.0 -> expected tcp://0.0.0.0:4243, got %s", addr)
281
+	}
282
+	if addr := ParseHost("127.0.0.1", 4243, "0.0.0.1:5555"); addr != "tcp://0.0.0.1:5555" {
283
+		t.Errorf("0.0.0.1:5555 -> expected tcp://0.0.0.1:5555, got %s", addr)
284
+	}
285
+	if addr := ParseHost("127.0.0.1", 4243, ":6666"); addr != "tcp://127.0.0.1:6666" {
286
+		t.Errorf(":6666 -> expected tcp://127.0.0.1:6666, got %s", addr)
287
+	}
288
+	if addr := ParseHost("127.0.0.1", 4243, "tcp://:7777"); addr != "tcp://127.0.0.1:7777" {
289
+		t.Errorf("tcp://:7777 -> expected tcp://127.0.0.1:7777, got %s", addr)
290
+	}
291
+	if addr := ParseHost("127.0.0.1", 4243, "unix:///var/run/docker.sock"); addr != "unix:///var/run/docker.sock" {
292
+		t.Errorf("unix:///var/run/docker.sock -> expected unix:///var/run/docker.sock, got %s", addr)
293
+	}
294
+}