github.com/sleungcy-sap/cli@v7.1.0+incompatible/integration/v7/global/org_quota_command_test.go (about)

     1  package global
     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("org-quota command", func() {
    12  	var (
    13  		quotaName string
    14  	)
    15  
    16  	BeforeEach(func() {
    17  		quotaName = helpers.QuotaName()
    18  	})
    19  
    20  	Describe("help", func() {
    21  		When("--help flag is set", func() {
    22  			It("Displays command usage to output", func() {
    23  				session := helpers.CF("org-quota", "--help")
    24  				Eventually(session).Should(Say("NAME:"))
    25  				Eventually(session).Should(Say("quota - Show organization quota"))
    26  				Eventually(session).Should(Say("USAGE:"))
    27  				Eventually(session).Should(Say("cf org-quota QUOTA"))
    28  				Eventually(session).Should(Say("ALIAS:"))
    29  				Eventually(session).Should(Say("quota"))
    30  				Eventually(session).Should(Say("SEE ALSO:"))
    31  				Eventually(session).Should(Say("org, org-quotas"))
    32  				Eventually(session).Should(Exit(0))
    33  			})
    34  		})
    35  	})
    36  
    37  	When("the environment is not setup correctly", func() {
    38  		It("fails with the appropriate errors", func() {
    39  			helpers.CheckEnvironmentTargetedCorrectly(false, false, ReadOnlyOrg, "org", "org-name")
    40  		})
    41  	})
    42  
    43  	When("the environment is set up correctly", func() {
    44  		BeforeEach(func() {
    45  			helpers.LoginCF()
    46  		})
    47  
    48  		When("the quota does not exist", func() {
    49  			It("displays quota not found and exits 1", func() {
    50  				session := helpers.CF("org-quota", quotaName)
    51  				userName, _ := helpers.GetCredentials()
    52  				Eventually(session).Should(Say(`Getting org quota %s as %s\.\.\.`, quotaName, userName))
    53  				Eventually(session.Err).Should(Say("Organization quota with name '%s' not found.", quotaName))
    54  				Eventually(session).Should(Say("FAILED"))
    55  				Eventually(session).Should(Exit(1))
    56  			})
    57  		})
    58  
    59  		When("the quota exists", func() {
    60  			When("no flags are used", func() {
    61  				It("displays a table with quota names and their values and exits 0", func() {
    62  					session := helpers.CF("org-quota", "default")
    63  					userName, _ := helpers.GetCredentials()
    64  					Eventually(session).Should(Say(`Getting org quota %s as %s\.\.\.`, "default", userName))
    65  
    66  					Eventually(session).Should(Say(`total memory:\s+100G`))
    67  					Eventually(session).Should(Say(`instance memory:\s+unlimited`))
    68  					Eventually(session).Should(Say(`routes:\s+1000`))
    69  					Eventually(session).Should(Say(`service instances:\s+unlimited`))
    70  					Eventually(session).Should(Say(`paid service plans:\s+allowed`))
    71  					Eventually(session).Should(Say(`app instances:\s+unlimited`))
    72  					Eventually(session).Should(Say(`route ports:\s+100`))
    73  
    74  					Eventually(session).Should(Exit(0))
    75  				})
    76  			})
    77  		})
    78  	})
    79  })