github.com/loafoe/cli@v7.1.0+incompatible/integration/shared/isolated/spaces_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("spaces command", func() {
    12  	var orgName string
    13  
    14  	BeforeEach(func() {
    15  		orgName = helpers.NewOrgName()
    16  	})
    17  
    18  	When("the environment is not setup correctly", func() {
    19  		It("fails with the appropriate errors", func() {
    20  			helpers.CheckEnvironmentTargetedCorrectly(true, false, ReadOnlyOrg, "spaces")
    21  		})
    22  	})
    23  
    24  	When("the environment is setup correctly", func() {
    25  		var username string
    26  
    27  		BeforeEach(func() {
    28  			username = helpers.LoginCF()
    29  			helpers.CreateOrg(orgName)
    30  			helpers.TargetOrg(orgName)
    31  		})
    32  
    33  		When("there are no spaces", func() {
    34  			It("displays no spaces found", func() {
    35  				session := helpers.CF("spaces")
    36  				Eventually(session).Should(Say(`Getting spaces in org %s as %s\.\.\.`, orgName, username))
    37  				Eventually(session).Should(Say(""))
    38  				Eventually(session).Should(Say(`No spaces found\.`))
    39  				Eventually(session).Should(Exit(0))
    40  			})
    41  		})
    42  
    43  		When("there are multiple spaces", func() {
    44  			var spaceName1, spaceName2, spaceName3, spaceName4, spaceName5, spaceName6 string
    45  
    46  			BeforeEach(func() {
    47  				spaceName1 = helpers.PrefixedRandomName("INTEGRATION-SPACE-DEF")
    48  				spaceName2 = helpers.PrefixedRandomName("INTEGRATION-SPACE-XYZ")
    49  				spaceName3 = helpers.PrefixedRandomName("INTEGRATION-SPACE-jop")
    50  				spaceName4 = helpers.PrefixedRandomName("INTEGRATION-SPACE-ABC")
    51  				spaceName5 = helpers.PrefixedRandomName("INTEGRATION-SPACE-543")
    52  				spaceName6 = helpers.PrefixedRandomName("INTEGRATION-SPACE-125")
    53  				helpers.CreateSpace(spaceName1)
    54  				helpers.CreateSpace(spaceName2)
    55  				helpers.CreateSpace(spaceName3)
    56  				helpers.CreateSpace(spaceName4)
    57  				helpers.CreateSpace(spaceName5)
    58  				helpers.CreateSpace(spaceName6)
    59  			})
    60  
    61  			It("displays a list of all spaces in the org in alphabetical order", func() {
    62  				session := helpers.CF("spaces")
    63  				Eventually(session).Should(Say(`Getting spaces in org %s as %s\.\.\.`, orgName, username))
    64  				Eventually(session).Should(Say(""))
    65  				Eventually(session).Should(Say("name"))
    66  				Eventually(session).Should(Say("%s\n%s\n%s\n%s\n%s\n%s", spaceName6, spaceName5, spaceName4, spaceName1, spaceName3, spaceName2))
    67  				Eventually(session).Should(Exit(0))
    68  			})
    69  		})
    70  	})
    71  })