github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/integration/experimental/v3_push_no_start_test.go (about)

     1  package experimental
     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("v3-push with --no-start", func() {
    12  	var (
    13  		orgName   string
    14  		spaceName string
    15  		appName   string
    16  		userName  string
    17  	)
    18  
    19  	BeforeEach(func() {
    20  		orgName = helpers.NewOrgName()
    21  		spaceName = helpers.NewSpaceName()
    22  		appName = helpers.PrefixedRandomName("app")
    23  		userName, _ = helpers.GetCredentials()
    24  	})
    25  
    26  	Context("when the environment is set up correctly", func() {
    27  		BeforeEach(func() {
    28  			setupCF(orgName, spaceName)
    29  		})
    30  
    31  		AfterEach(func() {
    32  			helpers.QuickDeleteOrg(orgName)
    33  		})
    34  
    35  		Context("when the app exists and is already running", func() {
    36  			var session *Session
    37  
    38  			BeforeEach(func() {
    39  				helpers.WithHelloWorldApp(func(appDir string) {
    40  					Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, "v3-push", appName)).Should(Exit(0))
    41  				})
    42  
    43  				It("uploads the app, does not restage or restart it, and stops the initial app", func() {
    44  					helpers.WithHelloWorldApp(func(appDir string) {
    45  						session = helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, "v3-push", appName, "--no-start")
    46  						Eventually(session).Should(Say("Updating app %s in org %s / space %s as %s\\.\\.\\.", appName, orgName, spaceName, userName))
    47  						Eventually(session).Should(Say("OK"))
    48  						Eventually(session).Should(Say(""))
    49  						Eventually(session).Should(Say("Uploading and creating bits package for app %s in org %s / space %s as %s\\.\\.\\.", appName, orgName, spaceName, userName))
    50  						Eventually(session).Should(Say("OK"))
    51  						Eventually(session).Should(Say(""))
    52  						Eventually(session).Should(Say("Stopping app %s in org %s / space %s as %s\\.\\.\\.", appName, orgName, spaceName, userName))
    53  						Eventually(session).Should(Say("OK"))
    54  						Eventually(session).Should(Say(""))
    55  						Consistently(session).ShouldNot(Say("Staging package for app %s in org %s / space %s as %s\\.\\.\\.", appName, orgName, spaceName, userName))
    56  						Consistently(session).ShouldNot(Say("Starting app %s in org %s / space %s as %s\\.\\.\\.", appName, orgName, spaceName, userName))
    57  						Eventually(session).Should(Exit(0))
    58  					})
    59  
    60  					session = helpers.CF("v3-app", appName)
    61  
    62  					Eventually(session).Should(Say("name:\\s+%s", appName))
    63  					Eventually(session).Should(Say("requested state:\\s+stopped"))
    64  
    65  					Eventually(session).Should(Say("web:1/1"))
    66  					Eventually(session).Should(Say(`state\s+since\s+cpu\s+memory\s+disk`))
    67  					Eventually(session).Should(Say("#0\\s+running\\s+\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2} [AP]M"))
    68  
    69  					Eventually(session).Should(Exit(0))
    70  				})
    71  			})
    72  		})
    73  
    74  		Context("when the app does not exist", func() {
    75  			var session *Session
    76  
    77  			It("uploads the app, does not restage or restart it", func() {
    78  				helpers.WithHelloWorldApp(func(appDir string) {
    79  					session = helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, "v3-push", appName, "--no-start")
    80  					Eventually(session).Should(Say("Creating app %s in org %s / space %s as %s\\.\\.\\.", appName, orgName, spaceName, userName))
    81  					Eventually(session).Should(Say("OK"))
    82  					Eventually(session).Should(Say(""))
    83  					Eventually(session).Should(Say("Uploading and creating bits package for app %s in org %s / space %s as %s\\.\\.\\.", appName, orgName, spaceName, userName))
    84  					Eventually(session).Should(Say("OK"))
    85  					Eventually(session).Should(Say(""))
    86  					Consistently(session).ShouldNot(Say("Staging package for app %s in org %s / space %s as %s\\.\\.\\.", appName, orgName, spaceName, userName))
    87  					Consistently(session).ShouldNot(Say("Starting app %s in org %s / space %s as %s\\.\\.\\.", appName, orgName, spaceName, userName))
    88  
    89  					Eventually(session).Should(Exit(0))
    90  				})
    91  			})
    92  		})
    93  	})
    94  })