- Remove `WaitRestart()` as it was no longer used
- Un-export `WaitForInspectResult()` as it was only used internally, and we want
to reduce uses of these utilities.
- Inline `appendDocker()` into `Docker()` as it was the only place it was used,
and the name was incorrect anyway (should've been named `prependXX`).
- Simplify `Args()`, as it was first splitting the slice (into `command` and `args`),
only to join them again into a single slice (in `icmd.Command()`).
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -42,22 +42,17 @@ func InspectCmd(t testing.TB, name string, cmdOperators ...CmdOperator) *icmd.Re |
| 42 | 42 |
|
| 43 | 43 |
// WaitRun will wait for the specified container to be running, maximum 5 seconds. |
| 44 | 44 |
func WaitRun(t testing.TB, name string, cmdOperators ...CmdOperator) {
|
| 45 |
- WaitForInspectResult(t, name, "{{.State.Running}}", "true", 5*time.Second, cmdOperators...)
|
|
| 45 |
+ waitForInspectResult(t, name, "{{.State.Running}}", "true", 5*time.Second, cmdOperators...)
|
|
| 46 | 46 |
} |
| 47 | 47 |
|
| 48 | 48 |
// WaitExited will wait for the specified container to state exit, subject |
| 49 | 49 |
// to a maximum time limit in seconds supplied by the caller |
| 50 | 50 |
func WaitExited(t testing.TB, name string, timeout time.Duration, cmdOperators ...CmdOperator) {
|
| 51 |
- WaitForInspectResult(t, name, "{{.State.Status}}", "exited", timeout, cmdOperators...)
|
|
| 51 |
+ waitForInspectResult(t, name, "{{.State.Status}}", "exited", timeout, cmdOperators...)
|
|
| 52 | 52 |
} |
| 53 | 53 |
|
| 54 |
-// WaitRestart will wait for the specified container to restart once |
|
| 55 |
-func WaitRestart(t testing.TB, name string, timeout time.Duration, cmdOperators ...CmdOperator) {
|
|
| 56 |
- WaitForInspectResult(t, name, "{{.RestartCount}}", "1", timeout, cmdOperators...)
|
|
| 57 |
-} |
|
| 58 |
- |
|
| 59 |
-// WaitForInspectResult waits for the specified expression to be equals to the specified expected string in the given time. |
|
| 60 |
-func WaitForInspectResult(t testing.TB, name, expr, expected string, timeout time.Duration, cmdOperators ...CmdOperator) {
|
|
| 54 |
+// waitForInspectResult waits for the specified expression to be equals to the specified expected string in the given time. |
|
| 55 |
+func waitForInspectResult(t testing.TB, name, expr, expected string, timeout time.Duration, cmdOperators ...CmdOperator) {
|
|
| 61 | 56 |
after := time.After(timeout) |
| 62 | 57 |
|
| 63 | 58 |
args := []string{"inspect", "-f", expr, name}
|
| ... | ... |
@@ -100,7 +95,7 @@ func Docker(cmd icmd.Cmd, cmdOperators ...CmdOperator) *icmd.Result {
|
| 100 | 100 |
defer deferFn() |
| 101 | 101 |
} |
| 102 | 102 |
} |
| 103 |
- appendDocker(&cmd) |
|
| 103 |
+ cmd.Command = append([]string{testEnv.DockerBinary()}, cmd.Command...)
|
|
| 104 | 104 |
if err := validateArgs(cmd.Command...); err != nil {
|
| 105 | 105 |
return &icmd.Result{
|
| 106 | 106 |
Error: err, |
| ... | ... |
@@ -148,20 +143,9 @@ func Format(format string) func(*icmd.Cmd) func() {
|
| 148 | 148 |
} |
| 149 | 149 |
} |
| 150 | 150 |
|
| 151 |
-func appendDocker(cmd *icmd.Cmd) {
|
|
| 152 |
- cmd.Command = append([]string{testEnv.DockerBinary()}, cmd.Command...)
|
|
| 153 |
-} |
|
| 154 |
- |
|
| 155 |
-// Args build an icmd.Cmd struct from the specified arguments |
|
| 156 |
-func Args(args ...string) icmd.Cmd {
|
|
| 157 |
- switch len(args) {
|
|
| 158 |
- case 0: |
|
| 159 |
- return icmd.Cmd{}
|
|
| 160 |
- case 1: |
|
| 161 |
- return icmd.Command(args[0]) |
|
| 162 |
- default: |
|
| 163 |
- return icmd.Command(args[0], args[1:]...) |
|
| 164 |
- } |
|
| 151 |
+// Args build an icmd.Cmd struct from the specified (command and) arguments. |
|
| 152 |
+func Args(commandAndArgs ...string) icmd.Cmd {
|
|
| 153 |
+ return icmd.Cmd{Command: commandAndArgs}
|
|
| 165 | 154 |
} |
| 166 | 155 |
|
| 167 | 156 |
// Daemon points to the specified daemon |