github.com/DaAlbrecht/cf-cli@v0.0.0-20231128151943-1fe19bb400b9/integration/v7/isolated/update_space_quota_command_test.go (about) 1 package isolated 2 3 import ( 4 "code.cloudfoundry.org/cli/api/cloudcontroller/ccversion" 5 "code.cloudfoundry.org/cli/integration/helpers" 6 . "github.com/onsi/ginkgo" 7 . "github.com/onsi/gomega" 8 . "github.com/onsi/gomega/gbytes" 9 . "github.com/onsi/gomega/gexec" 10 ) 11 12 var _ = Describe("update-space-quota command", func() { 13 var ( 14 quotaName string 15 ) 16 17 BeforeEach(func() { 18 quotaName = helpers.QuotaName() 19 }) 20 21 Describe("help", func() { 22 When("--help flag is set", func() { 23 It("Displays command usage to output", func() { 24 session := helpers.CF("update-space-quota", "--help") 25 Eventually(session).Should(Say("NAME:")) 26 Eventually(session).Should(Say("update-space-quota - Update an existing space quota")) 27 Eventually(session).Should(Say("USAGE:")) 28 Eventually(session).Should(Say(`cf update-space-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\] \[--allow-paid-service-plans\] \[--reserved-route-ports RESERVED_ROUTE_PORTS\] \[-l LOG_VOLUME\]`)) 29 Eventually(session).Should(Say("OPTIONS:")) 30 Eventually(session).Should(Say(`-a\s+Total number of application instances. -1 represents an unlimited amount.`)) 31 Eventually(session).Should(Say(`--allow-paid-service-plans\s+Allow provisioning instances of paid service plans.`)) 32 Eventually(session).Should(Say(`--disallow-paid-service-plans\s+Disallow provisioning instances of paid service plans.`)) 33 Eventually(session).Should(Say(`-i\s+Maximum amount of memory a process can have \(e.g. 1024M, 1G, 10G\). -1 represents an unlimited amount.`)) 34 Eventually(session).Should(Say(`-m\s+Total amount of memory all processes can have \(e.g. 1024M, 1G, 10G\). -1 represents an unlimited amount.`)) 35 Eventually(session).Should(Say(`-n\s+New name`)) 36 Eventually(session).Should(Say(`-r\s+Total number of routes. -1 represents an unlimited amount.`)) 37 Eventually(session).Should(Say(`--reserved-route-ports\s+Maximum number of routes that may be created with ports. -1 represents an unlimited amount.`)) 38 Eventually(session).Should(Say(`-s\s+Total number of service instances. -1 represents an unlimited amount.`)) 39 Eventually(session).Should(Say(`-l\s+Total log volume per second all processes can have, in bytes \(e.g. 128B, 4K, 1M\). -1 represents an unlimited amount.`)) 40 Eventually(session).Should(Say("SEE ALSO:")) 41 Eventually(session).Should(Say("space, space-quota, space-quotas")) 42 Eventually(session).Should(Exit(0)) 43 }) 44 }) 45 }) 46 47 When("the environment is not setup correctly", func() { 48 It("fails with the appropriate errors", func() { 49 helpers.CheckEnvironmentTargetedCorrectly(true, false, ReadOnlyOrg, "space-quota", quotaName) 50 }) 51 }) 52 53 When("the environment is set up correctly", func() { 54 var ( 55 orgName string 56 spaceName string 57 userName string 58 ) 59 60 BeforeEach(func() { 61 orgName = helpers.NewOrgName() 62 spaceName = helpers.NewSpaceName() 63 helpers.SetupCF(orgName, spaceName) 64 userName, _ = helpers.GetCredentials() 65 66 totalMemory := "24M" 67 instanceMemory := "6M" 68 routes := "8" 69 serviceInstances := "2" 70 appInstances := "3" 71 reservedRoutePorts := "1" 72 session := helpers.CF("create-space-quota", quotaName, "-m", totalMemory, "-i", instanceMemory, "-r", routes, "-s", serviceInstances, "-a", appInstances, "--allow-paid-service-plans", "--reserved-route-ports", reservedRoutePorts) 73 Eventually(session).Should(Exit(0)) 74 }) 75 76 AfterEach(func() { 77 helpers.QuickDeleteOrg(orgName) 78 }) 79 80 It("updates a space quota", func() { 81 totalMemory := "25M" 82 instanceMemory := "5M" 83 serviceInstances := "1" 84 appInstances := "2" 85 reservedRoutePorts := "0" 86 session := helpers.CF("update-space-quota", quotaName, "-m", totalMemory, "-i", instanceMemory, "-s", serviceInstances, "-a", appInstances, "--allow-paid-service-plans", "--reserved-route-ports", reservedRoutePorts) 87 Eventually(session).Should(Say("Updating space quota %s for org %s as %s...", quotaName, orgName, userName)) 88 Eventually(session).Should(Say("OK")) 89 Eventually(session).Should(Exit(0)) 90 91 session = helpers.CF("space-quota", quotaName) 92 Eventually(session).Should(Say(`total memory:\s+%s`, totalMemory)) 93 Eventually(session).Should(Say(`instance memory:\s+%s`, instanceMemory)) 94 Eventually(session).Should(Say(`routes:\s+%s`, "8")) 95 Eventually(session).Should(Say(`service instances:\s+%s`, serviceInstances)) 96 Eventually(session).Should(Say(`paid service plans:\s+%s`, "allowed")) 97 Eventually(session).Should(Say(`app instances:\s+%s`, appInstances)) 98 Eventually(session).Should(Say(`route ports:\s+%s`, reservedRoutePorts)) 99 Eventually(session).Should(Say(`log volume per second:\s+%s`, "unlimited")) 100 Eventually(session).Should(Exit(0)) 101 }) 102 103 When("CAPI supports log rate limits", func() { 104 BeforeEach(func() { 105 helpers.SkipIfVersionLessThan(ccversion.MinVersionLogRateLimitingV3) 106 }) 107 108 It("updates a quota", func() { 109 logVolume := "500B" 110 session := helpers.CF("update-space-quota", quotaName, "-l", logVolume) 111 Eventually(session).Should(Say("Updating space quota %s for org %s as %s...", quotaName, orgName, userName)) 112 Eventually(session).Should(Say("OK")) 113 Eventually(session).Should(Exit(0)) 114 115 session = helpers.CF("space-quota", quotaName) 116 Eventually(session).Should(Say(`log volume per second:\s+%s`, logVolume)) 117 Eventually(session).Should(Exit(0)) 118 }) 119 }) 120 121 When("the named quota does not exist", func() { 122 It("displays a missing quota error message and fails", func() { 123 session := helpers.CF("update-space-quota", "bogota") 124 Eventually(session).Should(Say(`Updating space quota bogota for org %s as %s\.\.\.`, orgName, userName)) 125 Eventually(session).Should(Say("FAILED")) 126 Eventually(session.Err).Should(Say("Space quota with name '%s' not found.", "bogota")) 127 Eventually(session).Should(Exit(1)) 128 }) 129 }) 130 131 When("conflicting flags are specified", func() { 132 It("displays a flag conflict error message and fails", func() { 133 session := helpers.CF("update-space-quota", quotaName, "--allow-paid-service-plans", "--disallow-paid-service-plans") 134 Eventually(session).Should(Say("FAILED")) 135 Eventually(session.Err).Should(Say(`Incorrect Usage: The following arguments cannot be used together: --allow-paid-service-plans, --disallow-paid-service-plans`)) 136 Eventually(session).Should(Exit(1)) 137 }) 138 }) 139 }) 140 })