github.com/randomtask1155/cli@v6.41.1-0.20181227003417-a98eed78cbde+incompatible/integration/v7/push/simple_manifest_only_test.go (about) 1 package push 2 3 import ( 4 "io/ioutil" 5 "os" 6 "path/filepath" 7 8 "code.cloudfoundry.org/cli/integration/helpers" 9 . "github.com/onsi/ginkgo" 10 . "github.com/onsi/gomega" 11 . "github.com/onsi/gomega/gbytes" 12 . "github.com/onsi/gomega/gexec" 13 ) 14 15 var _ = Describe("push with a simple manifest", func() { 16 var ( 17 appName string 18 ) 19 20 BeforeEach(func() { 21 appName = helpers.NewAppName() 22 }) 23 24 When("the manifest is in the current directory", func() { 25 It("uses the manifest", func() { 26 helpers.WithHelloWorldApp(func(dir string) { 27 helpers.WriteManifest(filepath.Join(dir, "manifest.yml"), map[string]interface{}{ 28 "applications": []map[string]interface{}{ 29 { 30 "name": appName, 31 "env": map[string]interface{}{ 32 "key1": "val1", 33 "key4": false, 34 }, 35 }, 36 }, 37 }) 38 39 session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName, "--no-start") 40 Eventually(session).Should(Exit(0)) 41 }) 42 43 session := helpers.CF("env", appName) 44 Eventually(session).Should(Say(`key1:\s+val1`)) 45 Eventually(session).Should(Say(`key4:\s+false`)) 46 Eventually(session).Should(Exit(0)) 47 }) 48 }) 49 50 When("the manifest is provided via '-f' flag", func() { 51 var ( 52 tempDir string 53 pathToManifest string 54 ) 55 56 BeforeEach(func() { 57 var err error 58 tempDir, err = ioutil.TempDir("", "simple-manifest-test") 59 Expect(err).ToNot(HaveOccurred()) 60 pathToManifest = filepath.Join(tempDir, "manifest.yml") 61 helpers.WriteManifest(pathToManifest, map[string]interface{}{ 62 "applications": []map[string]interface{}{ 63 { 64 "name": appName, 65 "env": map[string]interface{}{ 66 "key1": "val1", 67 "key4": false, 68 }, 69 }, 70 }, 71 }) 72 }) 73 74 AfterEach(func() { 75 Expect(os.RemoveAll(tempDir)).ToNot(HaveOccurred()) 76 }) 77 78 It("uses the manifest", func() { 79 helpers.WithHelloWorldApp(func(dir string) { 80 session := helpers.CustomCF( 81 helpers.CFEnv{WorkingDirectory: dir}, 82 PushCommandName, appName, 83 "-f", pathToManifest, 84 "--no-start") 85 Eventually(session).Should(Exit(0)) 86 }) 87 88 session := helpers.CF("env", appName) 89 Eventually(session).Should(Say(`key1:\s+val1`)) 90 Eventually(session).Should(Say(`key4:\s+false`)) 91 Eventually(session).Should(Exit(0)) 92 }) 93 }) 94 })