diff --git a/integration-cli/cli/cli.go b/integration-cli/cli/cli.go index 7b4796db4d..6ae29a9cf1 100644 --- a/integration-cli/cli/cli.go +++ b/integration-cli/cli/cli.go @@ -42,22 +42,17 @@ func InspectCmd(t testing.TB, name string, cmdOperators ...CmdOperator) *icmd.Re // WaitRun will wait for the specified container to be running, maximum 5 seconds. func WaitRun(t testing.TB, name string, cmdOperators ...CmdOperator) { - WaitForInspectResult(t, name, "{{.State.Running}}", "true", 5*time.Second, cmdOperators...) + waitForInspectResult(t, name, "{{.State.Running}}", "true", 5*time.Second, cmdOperators...) } // WaitExited will wait for the specified container to state exit, subject // to a maximum time limit in seconds supplied by the caller func WaitExited(t testing.TB, name string, timeout time.Duration, cmdOperators ...CmdOperator) { - WaitForInspectResult(t, name, "{{.State.Status}}", "exited", timeout, cmdOperators...) + waitForInspectResult(t, name, "{{.State.Status}}", "exited", timeout, cmdOperators...) } -// WaitRestart will wait for the specified container to restart once -func WaitRestart(t testing.TB, name string, timeout time.Duration, cmdOperators ...CmdOperator) { - WaitForInspectResult(t, name, "{{.RestartCount}}", "1", timeout, cmdOperators...) -} - -// WaitForInspectResult waits for the specified expression to be equals to the specified expected string in the given time. -func WaitForInspectResult(t testing.TB, name, expr, expected string, timeout time.Duration, cmdOperators ...CmdOperator) { +// waitForInspectResult waits for the specified expression to be equals to the specified expected string in the given time. +func waitForInspectResult(t testing.TB, name, expr, expected string, timeout time.Duration, cmdOperators ...CmdOperator) { after := time.After(timeout) args := []string{"inspect", "-f", expr, name} @@ -100,7 +95,7 @@ func Docker(cmd icmd.Cmd, cmdOperators ...CmdOperator) *icmd.Result { defer deferFn() } } - appendDocker(&cmd) + cmd.Command = append([]string{testEnv.DockerBinary()}, cmd.Command...) if err := validateArgs(cmd.Command...); err != nil { return &icmd.Result{ Error: err, @@ -148,20 +143,9 @@ func Format(format string) func(*icmd.Cmd) func() { } } -func appendDocker(cmd *icmd.Cmd) { - cmd.Command = append([]string{testEnv.DockerBinary()}, cmd.Command...) -} - -// Args build an icmd.Cmd struct from the specified arguments -func Args(args ...string) icmd.Cmd { - switch len(args) { - case 0: - return icmd.Cmd{} - case 1: - return icmd.Command(args[0]) - default: - return icmd.Command(args[0], args[1:]...) - } +// Args build an icmd.Cmd struct from the specified (command and) arguments. +func Args(commandAndArgs ...string) icmd.Cmd { + return icmd.Cmd{Command: commandAndArgs} } // Daemon points to the specified daemon