github.com/sleungcy-sap/cli@v7.1.0+incompatible/integration/v7/push/name_only_test.go (about) 1 package push 2 3 import ( 4 "code.cloudfoundry.org/cli/integration/helpers" 5 . "github.com/onsi/ginkgo" 6 . "github.com/onsi/gomega" 7 . "github.com/onsi/gomega/gbytes" 8 . "github.com/onsi/gomega/gexec" 9 ) 10 11 var _ = When("only the name is provided", func() { 12 var ( 13 appName string 14 userName string 15 ) 16 17 BeforeEach(func() { 18 appName = helpers.PrefixedRandomName("app") 19 userName, _ = helpers.GetCredentials() 20 }) 21 22 When("the app does not already exist", func() { 23 It("creates a new app", func() { 24 helpers.WithHelloWorldApp(func(appDir string) { 25 session := helpers.CustomCF( 26 helpers.CFEnv{WorkingDirectory: appDir}, 27 PushCommandName, appName, 28 ) 29 30 Eventually(session).Should(Say(`Pushing app %s to org %s / space %s as %s\.\.\.`, appName, organization, space, userName)) 31 Eventually(session).Should(Say(`Packaging files to upload\.\.\.`)) 32 Eventually(session).Should(Say(`Uploading files\.\.\.`)) 33 Eventually(session).Should(Say(`100.00%`)) 34 Eventually(session).Should(Say(`Waiting for API to complete processing files\.\.\.`)) 35 Eventually(session).Should(Say(`Staging app and tracing logs\.\.\.`)) 36 Eventually(session).Should(Say(`Waiting for app %s to start\.\.\.`, appName)) 37 Eventually(session).Should(Say(`name:\s+%s`, appName)) 38 Eventually(session).Should(Say(`requested state:\s+started`)) 39 Eventually(session).Should(Say(`routes:\s+%s.%s`, appName, helpers.DefaultSharedDomain())) 40 Eventually(session).Should(Say(`type:\s+web`)) 41 Eventually(session).Should(Say(`start command:\s+%s`, helpers.StaticfileBuildpackStartCommand)) 42 Eventually(session).Should(Exit(0)) 43 }) 44 }) 45 }) 46 47 When("the app exists", func() { 48 BeforeEach(func() { 49 helpers.WithHelloWorldApp(func(appDir string) { 50 Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, 51 PushCommandName, appName, 52 )).Should(Exit(0)) 53 }) 54 }) 55 56 It("pushes the app", func() { 57 helpers.WithHelloWorldApp(func(appDir string) { 58 session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, 59 PushCommandName, appName, 60 ) 61 62 Eventually(session).Should(Say(`Pushing app %s to org %s / space %s as %s\.\.\.`, appName, organization, space, userName)) 63 Eventually(session).Should(Say(`Packaging files to upload\.\.\.`)) 64 Eventually(session).Should(Say(`Uploading files\.\.\.`)) 65 Eventually(session).Should(Say(`100.00%`)) 66 Eventually(session).Should(Say(`Waiting for API to complete processing files\.\.\.`)) 67 Eventually(session).Should(Say(`Staging app and tracing logs\.\.\.`)) 68 Eventually(session).Should(Say(`Waiting for app %s to start\.\.\.`, appName)) 69 Eventually(session).Should(Say(`name:\s+%s`, appName)) 70 Eventually(session).Should(Say(`requested state:\s+started`)) 71 Eventually(session).Should(Say(`routes:\s+%s.%s`, appName, helpers.DefaultSharedDomain())) 72 Eventually(session).Should(Say(`type:\s+web`)) 73 Eventually(session).Should(Say(`start command:\s+%s`, helpers.StaticfileBuildpackStartCommand)) 74 Eventually(session).Should(Exit(0)) 75 }) 76 }) 77 }) 78 79 When("the app crashes", func() { 80 It("pushes the app", func() { 81 helpers.WithCrashingApp(func(appDir string) { 82 session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, PushCommandName, appName) 83 Eventually(session).Should(Say(`Pushing app %s to org %s / space %s as %s\.\.\.`, appName, organization, space, userName)) 84 Eventually(session).Should(Say(`Packaging files to upload\.\.\.`)) 85 Eventually(session).Should(Say(`Uploading files\.\.\.`)) 86 Eventually(session).Should(Say(`100.00%`)) 87 Eventually(session).Should(Say(`Waiting for API to complete processing files\.\.\.`)) 88 Eventually(session).Should(Say(`Staging app and tracing logs\.\.\.`)) 89 Eventually(session).Should(Say(`Waiting for app %s to start\.\.\.`, appName)) 90 Eventually(session).Should(Say(`name:\s+%s`, appName)) 91 Eventually(session).Should(Say(`requested state:\s+started`)) 92 Eventually(session).Should(Say(`type:\s+web`)) 93 Eventually(session).Should(Say(`start command:\s+bogus bogus`)) 94 Eventually(session).Should(Say(`#0\s+crashed`)) 95 Eventually(session.Err).Should(Say(`Start unsuccessful`)) 96 Eventually(session.Err).Should(Say(`TIP: use 'cf logs %s --recent' for more information`, appName)) 97 Eventually(session).Should(Exit(1)) 98 }) 99 }) 100 }) 101 })