github.com/cloudfoundry-attic/cli-with-i18n@v6.32.1-0.20171002233121-7401370d3b85+incompatible/integration/push/start_command_test.go (about) 1 package push 2 3 import ( 4 "path/filepath" 5 6 "code.cloudfoundry.org/cli/integration/helpers" 7 8 . "github.com/onsi/ginkgo" 9 . "github.com/onsi/gomega" 10 . "github.com/onsi/gomega/gbytes" 11 . "github.com/onsi/gomega/gexec" 12 ) 13 14 var _ = Describe("push with different start command values", func() { 15 var ( 16 appName string 17 ) 18 19 BeforeEach(func() { 20 appName = helpers.NewAppName() 21 }) 22 23 Context("when the start command flag is provided", func() { 24 It("sets the start command correctly for the pushed app", func() { 25 helpers.WithHelloWorldApp(func(dir string) { 26 By("pushing the app with no provided start command uses detected command") 27 session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName) 28 Eventually(session).Should(Say("start command:\\s+\\$HOME/boot.sh")) 29 Eventually(session).Should(Exit(0)) 30 31 By("pushing the app with a start command uses provided start command") 32 session = helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, 33 PushCommandName, appName, 34 "-c", "$HOME/boot.sh && echo hello") 35 Eventually(session).Should(Say("start command:\\s+\\$HOME/boot.sh && echo hello")) 36 Eventually(session).Should(Exit(0)) 37 38 By("pushing the app with no provided start command again uses previously set command") 39 session = helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName) 40 Eventually(session).Should(Say("start command:\\s+\\$HOME/boot.sh && echo hello")) 41 Eventually(session).Should(Exit(0)) 42 43 By("pushing the app with default uses detected command") 44 session = helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, 45 PushCommandName, appName, 46 "-c", "default") 47 Eventually(session).Should(Say("(?m)start command:\\s+\\$HOME/boot.sh$")) 48 Eventually(session).Should(Exit(0)) 49 50 By("pushing the app with null uses detected command") 51 session = helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, 52 PushCommandName, appName, 53 "-c", "null") 54 Eventually(session).Should(Say("(?m)start command:\\s+\\$HOME/boot.sh$")) 55 Eventually(session).Should(Exit(0)) 56 }) 57 }) 58 }) 59 60 Context("when the start command is provided in the manifest", func() { 61 It("sets the start command correctly for the pushed app", func() { 62 helpers.WithHelloWorldApp(func(dir string) { 63 By("pushing the app with no provided start command uses detected command") 64 helpers.WriteManifest(filepath.Join(dir, "manifest.yml"), map[string]interface{}{ 65 "applications": []map[string]interface{}{ 66 { 67 "name": appName, 68 "path": dir, 69 }, 70 }, 71 }) 72 session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName) 73 Eventually(session).Should(Say("start command:\\s+\\$HOME/boot.sh")) 74 Eventually(session).Should(Exit(0)) 75 76 By("pushing the app with a start command uses provided start command") 77 helpers.WriteManifest(filepath.Join(dir, "manifest.yml"), map[string]interface{}{ 78 "applications": []map[string]interface{}{ 79 { 80 "name": appName, 81 "path": dir, 82 "command": "$HOME/boot.sh && echo hello", 83 }, 84 }, 85 }) 86 session = helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName) 87 Eventually(session).Should(Say("start command:\\s+\\$HOME/boot.sh && echo hello")) 88 Eventually(session).Should(Exit(0)) 89 90 By("pushing the app with no provided start command again uses previously set command") 91 helpers.WriteManifest(filepath.Join(dir, "manifest.yml"), map[string]interface{}{ 92 "applications": []map[string]interface{}{ 93 { 94 "name": appName, 95 "path": dir, 96 }, 97 }, 98 }) 99 session = helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName) 100 Eventually(session).Should(Say("start command:\\s+\\$HOME/boot.sh && echo hello")) 101 Eventually(session).Should(Exit(0)) 102 103 By("pushing the app with default uses detected command") 104 helpers.WriteManifest(filepath.Join(dir, "manifest.yml"), map[string]interface{}{ 105 "applications": []map[string]interface{}{ 106 { 107 "name": appName, 108 "path": dir, 109 "command": "default", 110 }, 111 }, 112 }) 113 session = helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName) 114 Eventually(session).Should(Say("(?m)start command:\\s+\\$HOME/boot.sh$")) 115 Eventually(session).Should(Exit(0)) 116 117 By("pushing the app with null uses detected command") 118 helpers.WriteManifest(filepath.Join(dir, "manifest.yml"), map[string]interface{}{ 119 "applications": []map[string]interface{}{ 120 { 121 "name": appName, 122 "path": dir, 123 "command": nil, 124 }, 125 }, 126 }) 127 session = helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName) 128 Eventually(session).Should(Say("(?m)start command:\\s+\\$HOME/boot.sh$")) 129 Eventually(session).Should(Exit(0)) 130 }) 131 }) 132 }) 133 })