github.com/franc20/ayesa_sap@v7.0.0-beta.28.0.20200124003224-302d4d52fa6c+incompatible/integration/v7/isolated/stacks_command_test.go (about)

     1  package isolated
     2  
     3  import (
     4  	"regexp"
     5  
     6  	. "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers"
     7  	"code.cloudfoundry.org/cli/integration/helpers"
     8  	. "github.com/onsi/ginkgo"
     9  	. "github.com/onsi/gomega"
    10  	. "github.com/onsi/gomega/gbytes"
    11  	. "github.com/onsi/gomega/gexec"
    12  )
    13  
    14  var _ = Describe("stacks command", func() {
    15  	When("--help flag is set", func() {
    16  		It("appears in cf help -a", func() {
    17  			session := helpers.CF("help", "-a")
    18  			Eventually(session).Should(Exit(0))
    19  			Expect(session).To(HaveCommandInCategoryWithDescription("stacks", "APPS", "List all stacks (a stack is a pre-built file system, including an operating system, that can run apps)"))
    20  		})
    21  
    22  		It("Displays command usage to output", func() {
    23  			session := helpers.CF("stacks", "--help")
    24  
    25  			Eventually(session).Should(Say("NAME:"))
    26  			Eventually(session).Should(Say(regexp.QuoteMeta("stacks - List all stacks (a stack is a pre-built file system, including an operating system, that can run apps)")))
    27  			Eventually(session).Should(Say("USAGE:"))
    28  			Eventually(session).Should(Say(regexp.QuoteMeta("cf stacks [--labels SELECTOR]")))
    29  			Eventually(session).Should(Say("EXAMPLES:"))
    30  			Eventually(session).Should(Say("cf stacks"))
    31  			Eventually(session).Should(Say(regexp.QuoteMeta("cf stacks --labels 'environment in (production,staging),tier in (backend)'")))
    32  			Eventually(session).Should(Say(regexp.QuoteMeta("cf stacks --labels 'env=dev,!chargeback-code,tier in (backend,worker)'")))
    33  			Eventually(session).Should(Say("OPTIONS:"))
    34  			Eventually(session).Should(Say(`--labels\s+Selector to filter stacks by labels`))
    35  			Eventually(session).Should(Say("SEE ALSO:"))
    36  			Eventually(session).Should(Say("create-buildpack, delete-buildpack, rename-buildpack, stack, update-buildpack"))
    37  			Eventually(session).Should(Exit(0))
    38  		})
    39  	})
    40  
    41  	When("environment is not set up correctly", func() {
    42  		It("displays an error and exits 1", func() {
    43  			helpers.CheckEnvironmentTargetedCorrectly(false, false, ReadOnlyOrg, "stacks")
    44  		})
    45  	})
    46  
    47  	When("environment is set up correctly", func() {
    48  		var stackName string
    49  		var userName string
    50  
    51  		BeforeEach(func() {
    52  			helpers.SetupCF(ReadOnlyOrg, ReadOnlySpace)
    53  			stackName = helpers.NewStackName()
    54  			helpers.CreateStack(stackName)
    55  			helperSession := helpers.CF("set-label", "stack", stackName, "cool=ranch")
    56  
    57  			Eventually(helperSession).Should(Exit(0))
    58  			userName, _ = helpers.GetCredentials()
    59  		})
    60  
    61  		When("--labels flag is set", func() {
    62  
    63  			It("lists the filtered stacks by the flag", func() {
    64  				session := helpers.CF("stacks", "--labels", "cool in (ranch)")
    65  
    66  				Eventually(session).Should(Exit(0))
    67  
    68  				Expect(session).Should(Say(`Getting stacks as %s\.\.\.`, userName))
    69  				Expect(session).Should(Say(`name\s+description`))
    70  				Expect(session).Should(Say(`%s\s+CF CLI integration test stack, please delete`, stackName))
    71  
    72  				Expect(session).ShouldNot(Say(`cflinuxfs\d+\s+Cloud Foundry Linux`))
    73  
    74  			})
    75  		})
    76  
    77  		It("lists the stacks", func() {
    78  			session := helpers.CF("stacks")
    79  
    80  			Eventually(session).Should(Exit(0))
    81  
    82  			Expect(session).Should(Say(`Getting stacks as %s\.\.\.`, userName))
    83  			Expect(session).Should(Say(`name\s+description`))
    84  			Expect(session).Should(Say(`cflinuxfs\d+\s+Cloud Foundry Linux`))
    85  			Expect(session).Should(Say(`%s\s+CF CLI integration test stack, please delete`, stackName))
    86  		})
    87  	})
    88  })