github.com/sleungcy/cli@v7.1.0+incompatible/integration/v7/push/no_wait_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 _ = Describe("push with --no-wait", 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 exists", func() {
    23  		BeforeEach(func() {
    24  			helpers.WithHelloWorldApp(func(appDir string) {
    25  				Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir},
    26  					PushCommandName, appName,
    27  				)).Should(Exit(0))
    28  			})
    29  		})
    30  
    31  		It("pushes the app", func() {
    32  			helpers.WithHelloWorldApp(func(appDir string) {
    33  				session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir},
    34  					PushCommandName, appName, "--no-wait",
    35  				)
    36  
    37  				Eventually(session).Should(Say(`Pushing app %s to org %s / space %s as %s\.\.\.`, appName, organization, space, userName))
    38  				Eventually(session).Should(Say(`Packaging files to upload\.\.\.`))
    39  				Eventually(session).Should(Say(`Uploading files\.\.\.`))
    40  				Eventually(session).Should(Say(`100.00%`))
    41  				Eventually(session).Should(Say(`Waiting for API to complete processing files\.\.\.`))
    42  				Eventually(session).Should(Say(`Staging app and tracing logs\.\.\.`))
    43  				Eventually(session).Should(Say(`Waiting for app %s to start\.\.\.`, appName))
    44  				Eventually(session).Should(Say(`name:\s+%s`, appName))
    45  				Eventually(session).Should(Say(`requested state:\s+started`))
    46  				Eventually(session).Should(Say(`routes:\s+%s.%s`, appName, helpers.DefaultSharedDomain()))
    47  				Eventually(session).Should(Say(`type:\s+web`))
    48  				Eventually(session).Should(Say(`start command:\s+%s`, helpers.StaticfileBuildpackStartCommand))
    49  				Eventually(session).Should(Say(`#0\s+running`))
    50  				Eventually(session).Should(Exit(0))
    51  			})
    52  		})
    53  	})
    54  
    55  	When("the app does not exist", func() {
    56  		It("pushes the app", func() {
    57  			helpers.WithHelloWorldApp(func(appDir string) {
    58  				session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir},
    59  					PushCommandName, appName, "--no-wait",
    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(Say(`#0\s+running`))
    75  				Eventually(session).Should(Exit(0))
    76  			})
    77  		})
    78  	})
    79  
    80  	When("the app crashes", func() {
    81  		It("times out", func() {
    82  			helpers.WithCrashingApp(func(appDir string) {
    83  				session := helpers.CustomCF(helpers.CFEnv{
    84  					WorkingDirectory: appDir,
    85  					EnvVars:          map[string]string{"CF_STARTUP_TIMEOUT": "0.1"},
    86  				}, PushCommandName, appName, "--no-wait")
    87  				Eventually(session).Should(Say(`Pushing app %s to org %s / space %s as %s\.\.\.`, appName, organization, space, userName))
    88  				Eventually(session).Should(Say(`Packaging files to upload\.\.\.`))
    89  				Eventually(session).Should(Say(`Uploading files\.\.\.`))
    90  				Eventually(session).Should(Say(`100.00%`))
    91  				Eventually(session).Should(Say(`Waiting for API to complete processing files\.\.\.`))
    92  				Eventually(session).Should(Say(`Staging app and tracing logs\.\.\.`))
    93  				Eventually(session).Should(Say(`Waiting for app %s to start\.\.\.`, appName))
    94  				Eventually(session).Should(Say(`FAILED`))
    95  				Eventually(session.Err).Should(Say(`Start app timeout`))
    96  				Eventually(session.Err).Should(Say(`TIP: Application must be listening on the right port\. Instead of hard coding the port, use the \$PORT environment variable\.`))
    97  				Eventually(session.Err).Should(Say(`Use 'cf logs %s --recent' for more information`, appName))
    98  				Eventually(session).Should(Exit(1))
    99  			})
   100  		})
   101  	})
   102  })