Add first e2e test

Signed-off-by: Daniel Nephin <dnephin@docker.com>
Upstream-commit: b5cb5ee446
Component: cli
This commit is contained in:
Daniel Nephin
2017-08-16 10:46:40 -04:00
parent 581aa22bc8
commit 66fb82e7e8
5 changed files with 135 additions and 0 deletions
@@ -2,6 +2,7 @@ package stack
import (
"fmt"
"sort"
"strings"
"github.com/docker/cli/cli"
@@ -88,12 +89,19 @@ func runRemove(dockerCli command.Cli, opts removeOptions) error {
return nil
}
func sortServiceByName(services []swarm.Service) func(i, j int) bool {
return func(i, j int) bool {
return services[i].Spec.Name < services[j].Spec.Name
}
}
func removeServices(
ctx context.Context,
dockerCli command.Cli,
services []swarm.Service,
) bool {
var hasError bool
sort.Slice(services, sortServiceByName(services))
for _, service := range services {
fmt.Fprintf(dockerCli.Err(), "Removing service %s\n", service.Spec.Name)
if err := dockerCli.Client().ServiceRemove(ctx, service.ID); err != nil {