2017-02-22 15:43:13 -05:00
|
|
|
package stack
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/docker/docker/cli/compose/convert"
|
|
|
|
"github.com/docker/docker/cli/internal/test"
|
|
|
|
"github.com/docker/docker/pkg/testutil/assert"
|
|
|
|
"golang.org/x/net/context"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestPruneServices(t *testing.T) {
|
|
|
|
ctx := context.Background()
|
|
|
|
namespace := convert.NewNamespace("foo")
|
|
|
|
services := map[string]struct{}{
|
|
|
|
"new": {},
|
|
|
|
"keep": {},
|
|
|
|
}
|
2017-03-26 02:23:24 -04:00
|
|
|
client := &fakeClient{services: []string{objectName("foo", "keep"), objectName("foo", "remove")}}
|
2017-02-22 15:43:13 -05:00
|
|
|
dockerCli := test.NewFakeCli(client, &bytes.Buffer{})
|
|
|
|
dockerCli.SetErr(&bytes.Buffer{})
|
|
|
|
|
|
|
|
pruneServices(ctx, dockerCli, namespace, services)
|
|
|
|
|
2017-03-26 02:23:24 -04:00
|
|
|
assert.DeepEqual(t, client.removedServices, buildObjectIDs([]string{objectName("foo", "remove")}))
|
2017-02-22 15:43:13 -05:00
|
|
|
}
|