github.com/AliyunContainerService/cli@v0.0.0-20181009023821-814ced4b30d0/e2e/stack/deploy_test.go (about) 1 package stack 2 3 import ( 4 "fmt" 5 "sort" 6 "strings" 7 "testing" 8 9 "github.com/docker/cli/internal/test/environment" 10 "gotest.tools/assert" 11 "gotest.tools/golden" 12 "gotest.tools/icmd" 13 "gotest.tools/skip" 14 ) 15 16 func TestDeployWithNamedResources(t *testing.T) { 17 t.Run("Swarm", func(t *testing.T) { 18 testDeployWithNamedResources(t, "swarm") 19 }) 20 t.Run("Kubernetes", func(t *testing.T) { 21 // FIXME(chris-crone): currently does not work with compose for kubernetes. 22 t.Skip("FIXME(chris-crone): currently does not work with compose for kubernetes.") 23 skip.If(t, !environment.KubernetesEnabled()) 24 25 testDeployWithNamedResources(t, "kubernetes") 26 }) 27 } 28 29 func testDeployWithNamedResources(t *testing.T, orchestrator string) { 30 stackname := fmt.Sprintf("test-stack-deploy-with-names-%s", orchestrator) 31 composefile := golden.Path("stack-with-named-resources.yml") 32 33 result := icmd.RunCommand("docker", "stack", "deploy", 34 "-c", composefile, stackname, "--orchestrator", orchestrator) 35 defer icmd.RunCommand("docker", "stack", "rm", 36 "--orchestrator", orchestrator, stackname) 37 38 result.Assert(t, icmd.Success) 39 stdout := strings.Split(result.Stdout(), "\n") 40 expected := strings.Split(string(golden.Get(t, fmt.Sprintf("stack-deploy-with-names-%s.golden", orchestrator))), "\n") 41 sort.Strings(stdout) 42 sort.Strings(expected) 43 assert.DeepEqual(t, stdout, expected) 44 }