github.com/franc20/ayesa_sap@v7.0.0-beta.28.0.20200124003224-302d4d52fa6c+incompatible/integration/v6/global/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("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("quota", "--help")
    24  				Eventually(session).Should(Say("NAME:"))
    25  				Eventually(session).Should(Say("quota - Show quota info"))
    26  				Eventually(session).Should(Say("USAGE:"))
    27  				Eventually(session).Should(Say("cf quota QUOTA"))
    28  				Eventually(session).Should(Say("SEE ALSO:"))
    29  				Eventually(session).Should(Say("org, quotas"))
    30  				Eventually(session).Should(Exit(0))
    31  			})
    32  		})
    33  	})
    34  
    35  	When("the environment is not setup correctly", func() {
    36  		It("fails with the appropriate errors", func() {
    37  			helpers.CheckEnvironmentTargetedCorrectly(false, false, ReadOnlyOrg, "org", "org-name")
    38  		})
    39  	})
    40  
    41  	When("the environment is set up correctly", func() {
    42  		BeforeEach(func() {
    43  			helpers.LoginCF()
    44  		})
    45  
    46  		When("the quota does not exist", func() {
    47  			It("displays quota not found and exits 1", func() {
    48  				session := helpers.CF("quota", quotaName)
    49  				userName, _ := helpers.GetCredentials()
    50  				Eventually(session).Should(Say(`Getting quota %s info as %s\.\.\.`, quotaName, userName))
    51  				Eventually(session).Should(Say("FAILED"))
    52  				Eventually(session).Should(Say("Quota %s not found", quotaName))
    53  				Eventually(session).Should(Exit(1))
    54  			})
    55  		})
    56  
    57  		When("the quota exists", func() {
    58  			When("no flags are used", func() {
    59  				It("displays a table with quota names and their values and exits 0", func() {
    60  					session := helpers.CF("quota", "default")
    61  					userName, _ := helpers.GetCredentials()
    62  					Eventually(session).Should(Say(`Getting quota %s info as %s\.\.\.`, "default", userName))
    63  					Eventually(session).Should(Say("OK"))
    64  
    65  					Eventually(session).Should(Say(`Total Memory\s+100G`))
    66  					Eventually(session).Should(Say(`Instance Memory\s+unlimited`))
    67  					Eventually(session).Should(Say(`Routes\s+1000`))
    68  					Eventually(session).Should(Say(`Services\s+unlimited`))
    69  					Eventually(session).Should(Say(`Paid service plans\s+allowed`))
    70  					Eventually(session).Should(Say(`App instance limit\s+unlimited`))
    71  					Eventually(session).Should(Say(`Reserved Route Ports\s+100`))
    72  
    73  					Eventually(session).Should(Exit(0))
    74  				})
    75  			})
    76  		})
    77  	})
    78  })