浏览代码

Fix vet warning

Signed-off-by: Paul Mou <ppymou@gmail.com>
paul 10 年之前
父节点
当前提交
c5bf2145f1

+ 1 - 1
integration-cli/docker_api_containers_test.go

@@ -548,7 +548,7 @@ func TestPostContainerBindNormalVolume(t *testing.T) {
 	}
 
 	if fooDir2 != fooDir {
-		t.Fatal("expected volume path to be %s, got: %s", fooDir, fooDir2)
+		t.Fatalf("expected volume path to be %s, got: %s", fooDir, fooDir2)
 	}
 
 	logDone("container REST API - can use path from normal volume as bind-mount to overwrite another volume")

+ 8 - 8
integration-cli/docker_cli_daemon_test.go

@@ -524,7 +524,7 @@ func TestDaemonUlimitDefaults(t *testing.T) {
 
 	outArr := strings.Split(out, "\n")
 	if len(outArr) < 2 {
-		t.Fatal("got unexpected output: %s", out)
+		t.Fatalf("got unexpected output: %s", out)
 	}
 	nofile := strings.TrimSpace(outArr[0])
 	nproc := strings.TrimSpace(outArr[1])
@@ -548,7 +548,7 @@ func TestDaemonUlimitDefaults(t *testing.T) {
 
 	outArr = strings.Split(out, "\n")
 	if len(outArr) < 2 {
-		t.Fatal("got unexpected output: %s", out)
+		t.Fatalf("got unexpected output: %s", out)
 	}
 	nofile = strings.TrimSpace(outArr[0])
 	nproc = strings.TrimSpace(outArr[1])
@@ -616,9 +616,9 @@ func TestDaemonLoggingDriverDefault(t *testing.T) {
 		t.Fatal(err)
 	}
 	var res struct {
-		Log    string    `json:log`
-		Stream string    `json:stream`
-		Time   time.Time `json:time`
+		Log    string    `json:"log"`
+		Stream string    `json:"stream"`
+		Time   time.Time `json:"time"`
 	}
 	if err := json.NewDecoder(f).Decode(&res); err != nil {
 		t.Fatal(err)
@@ -712,9 +712,9 @@ func TestDaemonLoggingDriverNoneOverride(t *testing.T) {
 		t.Fatal(err)
 	}
 	var res struct {
-		Log    string    `json:log`
-		Stream string    `json:stream`
-		Time   time.Time `json:time`
+		Log    string    `json:"log"`
+		Stream string    `json:"stream"`
+		Time   time.Time `json:"time"`
 	}
 	if err := json.NewDecoder(f).Decode(&res); err != nil {
 		t.Fatal(err)

+ 1 - 1
integration-cli/docker_cli_links_test.go

@@ -75,7 +75,7 @@ func TestLinksInvalidContainerTarget(t *testing.T) {
 		t.Fatal("an invalid container target should produce an error")
 	}
 	if !strings.Contains(out, "Could not get container") {
-		t.Fatal("error output expected 'Could not get container', but got %q instead; err: %v", out, err)
+		t.Fatalf("error output expected 'Could not get container', but got %q instead; err: %v", out, err)
 	}
 
 	logDone("links - linking to non-existent container should not work")

+ 1 - 1
integration-cli/docker_cli_pause_test.go

@@ -22,7 +22,7 @@ func TestPause(t *testing.T) {
 		t.Fatalf("error thrown while checking if containers were paused: %v", err)
 	}
 	if len(pausedContainers) != 1 {
-		t.Fatalf("there should be one paused container and not", len(pausedContainers))
+		t.Fatalf("there should be one paused container and not %d", len(pausedContainers))
 	}
 
 	dockerCmd(t, "unpause", name)

+ 11 - 9
integration-cli/docker_cli_run_test.go

@@ -1930,9 +1930,9 @@ func TestRunAttachWithDettach(t *testing.T) {
 	cmd := exec.Command(dockerBinary, "run", "-d", "--attach", "stdout", "busybox", "true")
 	_, stderr, _, err := runCommandWithStdoutStderr(cmd)
 	if err == nil {
-		t.Fatalf("Container should have exited with error code different than 0", err)
+		t.Fatal("Container should have exited with error code different than 0")
 	} else if !strings.Contains(stderr, "Conflicting options: -a and -d") {
-		t.Fatalf("Should have been returned an error with conflicting options -a and -d")
+		t.Fatal("Should have been returned an error with conflicting options -a and -d")
 	}
 
 	logDone("run - Attach stdout with -d")
@@ -2655,7 +2655,7 @@ func TestRunCreateVolumeEtc(t *testing.T) {
 	cmd := exec.Command(dockerBinary, "run", "--dns=127.0.0.1", "-v", "/etc", "busybox", "cat", "/etc/resolv.conf")
 	out, _, err := runCommandWithOutput(cmd)
 	if err != nil {
-		t.Fatal("failed to run container: %v, output: %q", err, out)
+		t.Fatalf("failed to run container: %v, output: %q", err, out)
 	}
 	if !strings.Contains(out, "nameserver 127.0.0.1") {
 		t.Fatal("/etc volume mount hides /etc/resolv.conf")
@@ -2664,7 +2664,7 @@ func TestRunCreateVolumeEtc(t *testing.T) {
 	cmd = exec.Command(dockerBinary, "run", "-h=test123", "-v", "/etc", "busybox", "cat", "/etc/hostname")
 	out, _, err = runCommandWithOutput(cmd)
 	if err != nil {
-		t.Fatal("failed to run container: %v, output: %q", err, out)
+		t.Fatalf("failed to run container: %v, output: %q", err, out)
 	}
 	if !strings.Contains(out, "test123") {
 		t.Fatal("/etc volume mount hides /etc/hostname")
@@ -2673,7 +2673,7 @@ func TestRunCreateVolumeEtc(t *testing.T) {
 	cmd = exec.Command(dockerBinary, "run", "--add-host=test:192.168.0.1", "-v", "/etc", "busybox", "cat", "/etc/hosts")
 	out, _, err = runCommandWithOutput(cmd)
 	if err != nil {
-		t.Fatal("failed to run container: %v, output: %q", err, out)
+		t.Fatalf("failed to run container: %v, output: %q", err, out)
 	}
 	out = strings.Replace(out, "\n", " ", -1)
 	if !strings.Contains(out, "192.168.0.1\ttest") || !strings.Contains(out, "127.0.0.1\tlocalhost") {
@@ -2857,14 +2857,16 @@ func TestRunAllowPortRangeThroughExpose(t *testing.T) {
 		t.Fatal(err)
 	}
 	var ports nat.PortMap
-	err = unmarshalJSON([]byte(portstr), &ports)
+	if err = unmarshalJSON([]byte(portstr), &ports); err != nil {
+		t.Fatal(err)
+	}
 	for port, binding := range ports {
 		portnum, _ := strconv.Atoi(strings.Split(string(port), "/")[0])
 		if portnum < 3000 || portnum > 3003 {
-			t.Fatalf("Port is out of range ", portnum, binding, out)
+			t.Fatalf("Port %d is out of range ", portnum)
 		}
 		if binding == nil || len(binding) != 1 || len(binding[0].HostPort) == 0 {
-			t.Fatal("Port is not mapped for the port "+port, out)
+			t.Fatalf("Port is not mapped for the port %d", port)
 		}
 	}
 	if err := deleteContainer(id); err != nil {
@@ -3220,7 +3222,7 @@ func TestRunAllowPortRangeThroughPublish(t *testing.T) {
 	for port, binding := range ports {
 		portnum, _ := strconv.Atoi(strings.Split(string(port), "/")[0])
 		if portnum < 3000 || portnum > 3003 {
-			t.Fatalf("Port is out of range ", portnum, binding, out)
+			t.Fatalf("Port %d is out of range ", portnum)
 		}
 		if binding == nil || len(binding) != 1 || len(binding[0].HostPort) == 0 {
 			t.Fatal("Port is not mapped for the port "+port, out)

+ 1 - 1
integration-cli/docker_utils.go

@@ -1045,7 +1045,7 @@ func daemonTime(t *testing.T) time.Time {
 
 	body, err := sockRequest("GET", "/info", nil)
 	if err != nil {
-		t.Fatal("daemonTime: failed to get /info: %v", err)
+		t.Fatalf("daemonTime: failed to get /info: %v", err)
 	}
 
 	type infoJSON struct {