github.com/swisscom/cloudfoundry-cli@v7.1.0+incompatible/integration/v7/isolated/update_org_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("update-org-quota 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("update-org-quota", "--help") 16 Eventually(session).Should(Say("NAME:")) 17 Eventually(session).Should(Say("update-org-quota - Update an existing organization quota")) 18 Eventually(session).Should(Say("USAGE:")) 19 Eventually(session).Should(Say(`cf update-org-quota QUOTA [-m TOTAL_MEMORY] [-i INSTANCE_MEMORY] \[-n NEW_NAME\] \[-r ROUTES\] \[-s SERVICE_INSTANCES\] \[-a APP_INSTANCES\] \[--allow-paid-service-plans | --disallow-paid-service-plans\] \[--reserved-route-ports RESERVED_ROUTE_PORTS\]`)) 20 Eventually(session).Should(Say("ALIAS:")) 21 Eventually(session).Should(Say("update-quota")) 22 Eventually(session).Should(Say("OPTIONS:")) 23 Eventually(session).Should(Say(`-a\s+Total number of application instances. -1 represents an unlimited amount.`)) 24 Eventually(session).Should(Say(`--allow-paid-service-plans\s+Allow provisioning instances of paid service plans.`)) 25 Eventually(session).Should(Say(`--disallow-paid-service-plans\s+Disallow provisioning instances of paid service plans.`)) 26 Eventually(session).Should(Say(`-i\s+Maximum amount of memory a process can have \(e.g. 1024M, 1G, 10G\). -1 represents an unlimited amount.`)) 27 Eventually(session).Should(Say(`-m\s+Total amount of memory all processes can have \(e.g. 1024M, 1G, 10G\). -1 represents an unlimited amount.`)) 28 Eventually(session).Should(Say(`-n\s+New name`)) 29 Eventually(session).Should(Say(`-r\s+Total number of routes. -1 represents an unlimited amount.`)) 30 Eventually(session).Should(Say(`--reserved-route-ports\s+Maximum number of routes that may be created with ports. -1 represents an unlimited amount.`)) 31 Eventually(session).Should(Say(`-s\s+Total number of service instances. -1 represents an unlimited amount.`)) 32 Eventually(session).Should(Say("SEE ALSO:")) 33 Eventually(session).Should(Say("org, org-quota")) 34 Eventually(session).Should(Exit(0)) 35 }) 36 }) 37 }) 38 39 Describe("command behavior", func() { 40 var ( 41 orgName string 42 spaceName string 43 quotaName string 44 username string 45 ) 46 47 BeforeEach(func() { 48 orgName = helpers.NewOrgName() 49 spaceName = helpers.NewSpaceName() 50 username, _ = helpers.GetCredentials() 51 52 helpers.SetupCF(orgName, spaceName) 53 quotaName = helpers.QuotaName() 54 totalMemory := "24M" 55 instanceMemory := "6M" 56 routes := "8" 57 serviceInstances := "2" 58 appInstances := "3" 59 reservedRoutePorts := "1" 60 session := helpers.CF("create-org-quota", quotaName, "-m", totalMemory, "-i", instanceMemory, "-r", routes, "-s", serviceInstances, "-a", appInstances, "--allow-paid-service-plans", "--reserved-route-ports", reservedRoutePorts) 61 Eventually(session).Should(Exit(0)) 62 }) 63 64 AfterEach(func() { 65 helpers.QuickDeleteOrg(orgName) 66 }) 67 68 It("updates a quota", func() { 69 totalMemory := "25M" 70 instanceMemory := "5M" 71 serviceInstances := "1" 72 appInstances := "2" 73 reservedRoutePorts := "0" 74 session := helpers.CF("update-org-quota", quotaName, "-m", totalMemory, "-i", instanceMemory, "-s", serviceInstances, "-a", appInstances, "--disallow-paid-service-plans", "--reserved-route-ports", reservedRoutePorts) 75 Eventually(session).Should(Say(`Updating org quota %s as %s\.\.\.`, quotaName, username)) 76 Eventually(session).Should(Exit(0)) 77 78 session = helpers.CF("org-quota", quotaName) 79 Eventually(session).Should(Say(`total memory:\s+%s`, totalMemory)) 80 Eventually(session).Should(Say(`instance memory:\s+%s`, instanceMemory)) 81 Eventually(session).Should(Say(`routes:\s+%s`, "8")) 82 Eventually(session).Should(Say(`service instances:\s+%s`, serviceInstances)) 83 Eventually(session).Should(Say(`paid service plans:\s+%s`, "disallowed")) 84 Eventually(session).Should(Say(`app instances:\s+%s`, appInstances)) 85 Eventually(session).Should(Say(`route ports:\s+%s`, reservedRoutePorts)) 86 Eventually(session).Should(Exit(0)) 87 }) 88 89 When("the -n rename flag is provided", func() { 90 var newQuotaName string 91 92 BeforeEach(func() { 93 newQuotaName = helpers.QuotaName() 94 }) 95 96 It("renames the quota", func() { 97 session := helpers.CF("update-org-quota", quotaName, "-n", newQuotaName) 98 99 Eventually(session).Should(Say(`Updating org quota %s as %s\.\.\.`, quotaName, username)) 100 Eventually(session).Should(Exit(0)) 101 102 session = helpers.CF("org-quota", newQuotaName) 103 Eventually(session).Should(Exit(0)) 104 }) 105 106 When("an org quota with the new name already exists", func() { 107 It("returns an unprocessable error from the API", func() { 108 session := helpers.CF("update-org-quota", quotaName, "-n", "default") 109 110 Eventually(session.Err).Should(Say(`Organization Quota 'default' already exists\.`)) 111 Eventually(session).Should(Say("FAILED")) 112 Eventually(session).Should(Exit(1)) 113 }) 114 }) 115 }) 116 117 When("the named quota does not exist", func() { 118 It("displays a missing quota error message and fails", func() { 119 session := helpers.CF("update-org-quota", "bogus-org-quota") 120 Eventually(session).Should(Say(`Updating org quota bogus-org-quota as %s\.\.\.`, username)) 121 Eventually(session).Should(Say("FAILED")) 122 Eventually(session.Err).Should(Say("Organization quota with name '%s' not found.", "bogus-org-quota")) 123 Eventually(session).Should(Exit(1)) 124 }) 125 }) 126 127 When("no user-provided updates to the quota are specified", func() { 128 It("behaves idempotently and succeeds", func() { 129 session := helpers.CF("update-org-quota", quotaName) 130 Eventually(session).Should(Say(`Updating org quota %s as %s\.\.\.`, quotaName, username)) 131 Eventually(session).Should(Say("OK")) 132 Eventually(session).Should(Exit(0)) 133 }) 134 }) 135 136 When("conflicting flags are specified", func() { 137 It("displays a flag conflict error message and fails", func() { 138 session := helpers.CF("update-org-quota", quotaName, "--allow-paid-service-plans", "--disallow-paid-service-plans") 139 Eventually(session).Should(Say("FAILED")) 140 Eventually(session.Err).Should(Say(`Incorrect Usage: The following arguments cannot be used together: --allow-paid-service-plans, --disallow-paid-service-plans`)) 141 Eventually(session).Should(Exit(1)) 142 }) 143 }) 144 }) 145 })