Add some unit tests to the node and swarm cli code

Start work on adding unit tests to our cli code in order to have to
write less costly integration test.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
Vincent Demeester
2016-12-25 22:23:35 +01:00
parent 5d67ac20cb
commit ee8f9e084a
57 changed files with 2451 additions and 78 deletions

View File

@ -18,7 +18,7 @@ var (
errNoRoleChange = errors.New("role was already set to the requested value")
)
func newUpdateCommand(dockerCli *command.DockerCli) *cobra.Command {
func newUpdateCommand(dockerCli command.Cli) *cobra.Command {
nodeOpts := newNodeOptions()
cmd := &cobra.Command{
@ -39,14 +39,14 @@ func newUpdateCommand(dockerCli *command.DockerCli) *cobra.Command {
return cmd
}
func runUpdate(dockerCli *command.DockerCli, flags *pflag.FlagSet, nodeID string) error {
func runUpdate(dockerCli command.Cli, flags *pflag.FlagSet, nodeID string) error {
success := func(_ string) {
fmt.Fprintln(dockerCli.Out(), nodeID)
}
return updateNodes(dockerCli, []string{nodeID}, mergeNodeUpdate(flags), success)
}
func updateNodes(dockerCli *command.DockerCli, nodes []string, mergeNode func(node *swarm.Node) error, success func(nodeID string)) error {
func updateNodes(dockerCli command.Cli, nodes []string, mergeNode func(node *swarm.Node) error, success func(nodeID string)) error {
client := dockerCli.Client()
ctx := context.Background()