github.com/loafoe/cli@v7.1.0+incompatible/integration/v7/isolated/space_quota_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("space-quota command", func() { 12 var ( 13 quotaName string 14 orgName string 15 ) 16 17 BeforeEach(func() { 18 quotaName = helpers.QuotaName() 19 orgName = helpers.NewOrgName() 20 }) 21 22 Describe("help", func() { 23 When("--help flag is set", func() { 24 It("Displays command usage to output", func() { 25 session := helpers.CF("space-quota", "--help") 26 Eventually(session).Should(Say("NAME:")) 27 Eventually(session).Should(Say("space-quota - Show space quota info")) 28 Eventually(session).Should(Say("USAGE:")) 29 Eventually(session).Should(Say("cf space-quota QUOTA")) 30 Eventually(session).Should(Say("SEE ALSO:")) 31 Eventually(session).Should(Say("space, space-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(true, false, ReadOnlyOrg, "space-quota", quotaName) 40 }) 41 }) 42 43 When("the environment is set up correctly", func() { 44 var userName string 45 46 BeforeEach(func() { 47 userName = helpers.LoginCF() 48 helpers.CreateOrg(orgName) 49 helpers.TargetOrg(orgName) 50 }) 51 52 When("the quota does not exist", func() { 53 It("displays quota not found and exits 1", func() { 54 session := helpers.CF("space-quota", quotaName) 55 userName, _ := helpers.GetCredentials() 56 Eventually(session).Should(Say(`Getting space quota %s for org %s as %s\.\.\.`, quotaName, orgName, userName)) 57 Eventually(session.Err).Should(Say("Space quota with name '%s' not found.", quotaName)) 58 Eventually(session).Should(Say("FAILED")) 59 Eventually(session).Should(Exit(1)) 60 }) 61 }) 62 63 When("the quota exists", func() { 64 BeforeEach(func() { 65 session := helpers.CF( 66 "create-space-quota", 67 quotaName, 68 "--allow-paid-service-plans", 69 "-i", "6M", 70 "-m", "7M", 71 "-r", "8", 72 "--reserved-route-ports", "0", 73 "-s", "-1") 74 Eventually(session).Should(Exit(0)) 75 }) 76 77 It("displays a table with quota names and their values and exits 0", func() { 78 session := helpers.CF("space-quota", quotaName) 79 80 Eventually(session).Should(Say(`Getting space quota %s for org %s as %s\.\.\.`, quotaName, orgName, userName)) 81 Eventually(session).Should(Say(`total memory:\s+7M`)) 82 Eventually(session).Should(Say(`instance memory:\s+6M`)) 83 Eventually(session).Should(Say(`routes:\s+8`)) 84 Eventually(session).Should(Say(`service instances:\s+unlimited`)) 85 Eventually(session).Should(Say(`paid service plans:\s+allowed`)) 86 Eventually(session).Should(Say(`app instances:\s+unlimited`)) 87 Eventually(session).Should(Say(`route ports:\s+0`)) 88 89 Eventually(session).Should(Exit(0)) 90 }) 91 }) 92 }) 93 })