Handle some TODOs in tests
Use more gotestyourself for `env.Patch`, and `icmd.RunCommand` Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
@ -1,13 +1,10 @@
|
||||
package stack
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/cli/internal/test/environment"
|
||||
shlex "github.com/flynn-archive/go-shlex"
|
||||
"github.com/gotestyourself/gotestyourself/assert"
|
||||
"github.com/gotestyourself/gotestyourself/golden"
|
||||
"github.com/gotestyourself/gotestyourself/icmd"
|
||||
"github.com/gotestyourself/gotestyourself/poll"
|
||||
@ -20,7 +17,7 @@ func TestRemove(t *testing.T) {
|
||||
deployFullStack(t, stackname)
|
||||
defer cleanupFullStack(t, stackname)
|
||||
|
||||
result := icmd.RunCmd(shell(t, "docker stack rm %s", stackname))
|
||||
result := icmd.RunCommand("docker", "stack", "rm", stackname)
|
||||
|
||||
result.Assert(t, icmd.Expected{Err: icmd.None})
|
||||
golden.Assert(t, result.Stdout(), "stack-remove-success.golden")
|
||||
@ -28,8 +25,8 @@ func TestRemove(t *testing.T) {
|
||||
|
||||
func deployFullStack(t *testing.T, stackname string) {
|
||||
// TODO: this stack should have full options not minimal options
|
||||
result := icmd.RunCmd(shell(t,
|
||||
"docker stack deploy --compose-file=./testdata/full-stack.yml %s", stackname))
|
||||
result := icmd.RunCommand("docker", "stack", "deploy",
|
||||
"--compose-file=./testdata/full-stack.yml", stackname)
|
||||
result.Assert(t, icmd.Success)
|
||||
|
||||
poll.WaitOn(t, taskCount(stackname, 2), pollSettings)
|
||||
@ -66,10 +63,3 @@ func taskCount(stackname string, expected int) func(t poll.LogT) poll.Result {
|
||||
func lines(out string) int {
|
||||
return len(strings.Split(strings.TrimSpace(out), "\n"))
|
||||
}
|
||||
|
||||
// TODO: move to gotestyourself
|
||||
func shell(t *testing.T, format string, args ...interface{}) icmd.Cmd {
|
||||
cmd, err := shlex.Split(fmt.Sprintf(format, args...))
|
||||
assert.NilError(t, err)
|
||||
return icmd.Cmd{Command: cmd}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user