github.com/orange-cloudfoundry/cli@v7.1.0+incompatible/integration/v7/push/stacks_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("stack", func() {
    12  	var (
    13  		appName   string
    14  		stackName string
    15  	)
    16  
    17  	BeforeEach(func() {
    18  		appName = helpers.PrefixedRandomName("app")
    19  		stackName = helpers.CreateStack()
    20  	})
    21  
    22  	AfterEach(func() {
    23  		buffer := NewBuffer()
    24  		_, err := buffer.Write([]byte("y\n"))
    25  		Expect(err).ToNot(HaveOccurred())
    26  		session := helpers.CFWithStdin(buffer, "delete", appName)
    27  		Eventually(session).Should(Exit(0))
    28  		helpers.DeleteStack(stackName)
    29  	})
    30  
    31  	When("the --stack flag is provided", func() {
    32  		It("successfully pushes the app with the provided stack", func() {
    33  			helpers.WithHelloWorldApp(func(appDir string) {
    34  				session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir},
    35  					PushCommandName, appName,
    36  					"--stack", stackName,
    37  					"--no-start",
    38  				)
    39  				Eventually(session).Should(Exit(0))
    40  				Expect(helpers.AppJSON(appName)).To(MatchRegexp(`"stack":\s*"%s"`, stackName))
    41  			})
    42  		})
    43  
    44  		It("fails to push the app with an invalid stack", func() {
    45  			helpers.WithHelloWorldApp(func(appDir string) {
    46  				session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir},
    47  					PushCommandName, appName,
    48  					"--stack", "invalidStack",
    49  				)
    50  
    51  				Eventually(session.Err).Should(Say(`Stack must be an existing stack`))
    52  				Eventually(session).Should(Say("FAILED"))
    53  				Eventually(session).Should(Exit(1))
    54  			})
    55  		})
    56  	})
    57  })