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