From c5bf2145f172a264d3d8fc63d6717826b95b5ee2 Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 25 Mar 2015 20:18:42 -0700 Subject: [PATCH] Fix vet warning Signed-off-by: Paul Mou --- integration-cli/docker_api_containers_test.go | 2 +- integration-cli/docker_cli_daemon_test.go | 16 +++++++-------- integration-cli/docker_cli_links_test.go | 2 +- integration-cli/docker_cli_pause_test.go | 2 +- integration-cli/docker_cli_run_test.go | 20 ++++++++++--------- integration-cli/docker_utils.go | 2 +- 6 files changed, 23 insertions(+), 21 deletions(-) diff --git a/integration-cli/docker_api_containers_test.go b/integration-cli/docker_api_containers_test.go index ea2f2450a9..a85fcbdf6b 100644 --- a/integration-cli/docker_api_containers_test.go +++ b/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") diff --git a/integration-cli/docker_cli_daemon_test.go b/integration-cli/docker_cli_daemon_test.go index c515a63787..7531e431c4 100644 --- a/integration-cli/docker_cli_daemon_test.go +++ b/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) diff --git a/integration-cli/docker_cli_links_test.go b/integration-cli/docker_cli_links_test.go index efee8d04e3..1b46da50a3 100644 --- a/integration-cli/docker_cli_links_test.go +++ b/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") diff --git a/integration-cli/docker_cli_pause_test.go b/integration-cli/docker_cli_pause_test.go index f1ccde9cfc..2ba8cb0ae6 100644 --- a/integration-cli/docker_cli_pause_test.go +++ b/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) diff --git a/integration-cli/docker_cli_run_test.go b/integration-cli/docker_cli_run_test.go index 26cfcccde4..1e4a51162a 100644 --- a/integration-cli/docker_cli_run_test.go +++ b/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) diff --git a/integration-cli/docker_utils.go b/integration-cli/docker_utils.go index 7abdc54dce..fabd214922 100644 --- a/integration-cli/docker_utils.go +++ b/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 {