2018-03-12 15:02:18 -04:00
|
|
|
package stack
|
|
|
|
|
|
|
|
import (
|
2018-05-17 07:17:55 -04:00
|
|
|
"fmt"
|
2018-03-12 15:02:18 -04:00
|
|
|
"sort"
|
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
|
2018-05-17 07:17:55 -04:00
|
|
|
"github.com/docker/cli/internal/test/environment"
|
2018-06-08 12:24:26 -04:00
|
|
|
"gotest.tools/assert"
|
|
|
|
"gotest.tools/golden"
|
|
|
|
"gotest.tools/icmd"
|
|
|
|
"gotest.tools/skip"
|
2018-03-12 15:02:18 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestDeployWithNamedResources(t *testing.T) {
|
2018-05-17 07:17:55 -04:00
|
|
|
t.Run("Swarm", func(t *testing.T) {
|
|
|
|
testDeployWithNamedResources(t, "swarm")
|
|
|
|
})
|
|
|
|
t.Run("Kubernetes", func(t *testing.T) {
|
|
|
|
// FIXME(chris-crone): currently does not work with compose for kubernetes.
|
|
|
|
t.Skip("FIXME(chris-crone): currently does not work with compose for kubernetes.")
|
|
|
|
skip.If(t, !environment.KubernetesEnabled())
|
|
|
|
|
|
|
|
testDeployWithNamedResources(t, "kubernetes")
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func testDeployWithNamedResources(t *testing.T, orchestrator string) {
|
|
|
|
stackname := fmt.Sprintf("test-stack-deploy-with-names-%s", orchestrator)
|
2018-03-12 15:02:18 -04:00
|
|
|
composefile := golden.Path("stack-with-named-resources.yml")
|
|
|
|
|
2018-05-17 07:17:55 -04:00
|
|
|
result := icmd.RunCommand("docker", "--orchestrator", orchestrator,
|
|
|
|
"stack", "deploy", "-c", composefile, stackname)
|
|
|
|
defer icmd.RunCommand("docker", "--orchestrator", orchestrator,
|
|
|
|
"stack", "rm", stackname)
|
2018-03-12 15:02:18 -04:00
|
|
|
|
|
|
|
result.Assert(t, icmd.Success)
|
|
|
|
stdout := strings.Split(result.Stdout(), "\n")
|
2018-05-17 07:17:55 -04:00
|
|
|
expected := strings.Split(string(golden.Get(t, fmt.Sprintf("stack-deploy-with-names-%s.golden", orchestrator))), "\n")
|
2018-03-12 15:02:18 -04:00
|
|
|
sort.Strings(stdout)
|
|
|
|
sort.Strings(expected)
|
|
|
|
assert.DeepEqual(t, stdout, expected)
|
|
|
|
}
|