github.com/franc20/ayesa_sap@v7.0.0-beta.28.0.20200124003224-302d4d52fa6c+incompatible/integration/v6/isolated/orgs_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("orgs command", func() {
    12  	Describe("help", func() {
    13  		When("--help flag is set", func() {
    14  			It("displays command usage to output", func() {
    15  				session := helpers.CF("orgs", "--help")
    16  				Eventually(session).Should(Say("NAME:"))
    17  				Eventually(session).Should(Say(`\s+orgs - List all orgs`))
    18  				Eventually(session).Should(Say("USAGE:"))
    19  				Eventually(session).Should(Say(`\s+cf orgs`))
    20  				Eventually(session).Should(Say("ALIAS:"))
    21  				Eventually(session).Should(Say(`\s+o`))
    22  				Eventually(session).Should(Exit(0))
    23  			})
    24  		})
    25  	})
    26  
    27  	When("the environment is not setup correctly", func() {
    28  		It("fails with the appropriate errors", func() {
    29  			helpers.CheckEnvironmentTargetedCorrectly(false, false, ReadOnlyOrg, "orgs")
    30  		})
    31  	})
    32  
    33  	When("the environment is setup correctly", func() {
    34  		var username string
    35  
    36  		BeforeEach(func() {
    37  			username = helpers.LoginCF()
    38  		})
    39  
    40  		When("there are multiple orgs", func() {
    41  			var orgName1, orgName2, orgName3, orgName4, orgName5 string
    42  
    43  			BeforeEach(func() {
    44  				orgName1 = helpers.PrefixedRandomName("INTEGRATION-ORG-XYZ")
    45  				orgName2 = helpers.PrefixedRandomName("INTEGRATION-ORG-456")
    46  				orgName3 = helpers.PrefixedRandomName("INTEGRATION-ORG-ABC")
    47  				orgName4 = helpers.PrefixedRandomName("INTEGRATION-ORG-123")
    48  				orgName5 = helpers.PrefixedRandomName("INTEGRATION-ORG-ghi")
    49  				helpers.CreateOrg(orgName1)
    50  				helpers.CreateOrg(orgName2)
    51  				helpers.CreateOrg(orgName3)
    52  				helpers.CreateOrg(orgName4)
    53  				helpers.CreateOrg(orgName5)
    54  			})
    55  
    56  			AfterEach(func() {
    57  				helpers.QuickDeleteOrg(orgName1)
    58  				helpers.QuickDeleteOrg(orgName2)
    59  				helpers.QuickDeleteOrg(orgName3)
    60  				helpers.QuickDeleteOrg(orgName4)
    61  				helpers.QuickDeleteOrg(orgName5)
    62  			})
    63  
    64  			It("displays a list of all orgs", func() {
    65  				session := helpers.CF("orgs")
    66  				Eventually(session).Should(Say(`Getting orgs as %s\.\.\.`, username))
    67  				Eventually(session).Should(Say(""))
    68  				Eventually(session).Should(Say("name"))
    69  				Eventually(session).Should(Say("%s", orgName4))
    70  				Eventually(session).Should(Say("%s", orgName2))
    71  				Eventually(session).Should(Say("%s", orgName3))
    72  				Eventually(session).Should(Say("%s", orgName5))
    73  				Eventually(session).Should(Say("%s", orgName1))
    74  				Eventually(session).Should(Exit(0))
    75  			})
    76  		})
    77  	})
    78  })