Skip to content

Commit

Permalink
Fix vet warning
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Mou <[email protected]>
  • Loading branch information
paul committed Mar 26, 2015
1 parent f84086b commit c5bf214
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion integration-cli/docker_api_containers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
16 changes: 8 additions & 8 deletions integration-cli/docker_cli_daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -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])
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion integration-cli/docker_cli_links_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion integration-cli/docker_cli_pause_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
20 changes: 11 additions & 9 deletions integration-cli/docker_cli_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand All @@ -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")
Expand All @@ -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") {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion integration-cli/docker_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit c5bf214

Please sign in to comment.