docker-cli/cli/command/stack/deploy_test.go
Daniel Nephin 69b142b52a Update FakeCli to remove duplication in tests.
Use byte buffers by default, since that is what is done most of the time.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-07-11 14:49:30 -04:00

28 lines
728 B
Go

package stack
import (
"bytes"
"testing"
"github.com/docker/cli/cli/compose/convert"
"github.com/docker/cli/cli/internal/test"
"github.com/stretchr/testify/assert"
"golang.org/x/net/context"
)
func TestPruneServices(t *testing.T) {
ctx := context.Background()
namespace := convert.NewNamespace("foo")
services := map[string]struct{}{
"new": {},
"keep": {},
}
client := &fakeClient{services: []string{objectName("foo", "keep"), objectName("foo", "remove")}}
dockerCli := test.NewFakeCliWithOutput(client, &bytes.Buffer{})
dockerCli.SetErr(&bytes.Buffer{})
pruneServices(ctx, dockerCli, namespace, services)
assert.Equal(t, buildObjectIDs([]string{objectName("foo", "remove")}), client.removedServices)
}