github.com/jenspinney/cli@v6.42.1-0.20190207184520-7450c600020e+incompatible/integration/v7/isolated/stacks_command_test.go (about)

     1  package isolated
     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("stacks command", func() {
    12  	When("--help flag is set", func() {
    13  		It("Displays command usage to output", func() {
    14  			session := helpers.CF("stacks", "--help")
    15  
    16  			Eventually(session).Should(Say("NAME:"))
    17  			Eventually(session).Should(Say(`stacks - List all stacks \(a stack is a pre-built file system, including an operating system, that can run apps\)`))
    18  			Eventually(session).Should(Say("USAGE:"))
    19  			Eventually(session).Should(Say(`cf stacks`))
    20  			Eventually(session).Should(Say("SEE ALSO:"))
    21  			Eventually(session).Should(Say(`app, push`))
    22  
    23  			Eventually(session).Should(Exit(0))
    24  		})
    25  	})
    26  
    27  	When("environment is not set up correctly", func() {
    28  		It("displays an error and exits 1", func() {
    29  			helpers.CheckEnvironmentTargetedCorrectly(false, false, ReadOnlyOrg, "stacks")
    30  		})
    31  	})
    32  
    33  	When("environment is set up correctly", func() {
    34  		var stackName string
    35  
    36  		BeforeEach(func() {
    37  			helpers.SetupCF(ReadOnlyOrg, ReadOnlySpace)
    38  			stackName = helpers.NewStackName()
    39  			helpers.CreateStack(stackName)
    40  		})
    41  
    42  		It("lists the stacks", func() {
    43  			session := helpers.CF("stacks")
    44  
    45  			username, _ := helpers.GetCredentials()
    46  			Eventually(session).Should(Say(`Getting stacks as %s\.\.\.`, username))
    47  			Eventually(session).Should(Say(`name\s+description`))
    48  			Eventually(session).Should(Say(`cflinuxfs\d+\s+Cloud Foundry Linux`))
    49  			Eventually(session).Should(Say(`%s\s+CF CLI integration test stack, please delete`, stackName))
    50  			Eventually(session).Should(Exit(0))
    51  		})
    52  	})
    53  })