github.com/loafoe/cli@v7.1.0+incompatible/integration/v7/isolated/delete_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("delete-space-quota command", func() { 12 Describe("help text", func() { 13 When("the --help flag is passed", func() { 14 It("Displays the appropriate help text", func() { 15 session := helpers.CF("delete-space-quota", "--help") 16 Eventually(session).Should(Say("NAME:")) 17 Eventually(session).Should(Say("delete-space-quota - Delete a space quota")) 18 Eventually(session).Should(Say("\n")) 19 Eventually(session).Should(Say("USAGE:")) 20 Eventually(session).Should(Say(`cf delete-space-quota QUOTA \[-f]`)) 21 Eventually(session).Should(Say("\n")) 22 Eventually(session).Should(Say("OPTIONS:")) 23 Eventually(session).Should(Say(`--force, -f\s+Force deletion without confirmation`)) 24 Eventually(session).Should(Say("\n")) 25 Eventually(session).Should(Say("SEE ALSO:")) 26 Eventually(session).Should(Say("space-quotas")) 27 Eventually(session).Should(Exit(0)) 28 }) 29 }) 30 }) 31 32 Describe("command behavior", func() { 33 var ( 34 quotaName string 35 userName string 36 orgName string 37 ) 38 39 BeforeEach(func() { 40 orgName = helpers.NewOrgName() 41 helpers.SetupCFWithOrgOnly(orgName) 42 quotaName = helpers.QuotaName() 43 userName, _ = helpers.GetCredentials() 44 }) 45 46 When("deleting a space quota", func() { 47 var buffer *Buffer 48 49 BeforeEach(func() { 50 buffer = NewBuffer() 51 session := helpers.CF("create-space-quota", quotaName) 52 Eventually(session).Should(Exit(0)) 53 54 _, err := buffer.Write([]byte("y\n")) 55 Expect(err).ToNot(HaveOccurred()) 56 }) 57 58 It("prompts for confirmation and deletes the space quota", func() { 59 session := helpers.CFWithStdin(buffer, "delete-space-quota", quotaName) 60 Eventually(session).Should(Say(`Really delete the space quota %s in org %s\? \[yN\]`, quotaName, orgName)) 61 Eventually(session).Should(Say(`Deleting space quota %s for org %s as %s\.\.\.`, quotaName, orgName, userName)) 62 Eventually(session).Should(Say("OK")) 63 Eventually(session).Should(Exit(0)) 64 65 session = helpers.CF("space-quotas") 66 Eventually(session).Should(Exit(0)) 67 Expect(session.Out.Contents()).NotTo(ContainSubstring(quotaName)) 68 }) 69 }) 70 71 Context("the -f flag is provided", func() { 72 BeforeEach(func() { 73 session := helpers.CF("create-space-quota", quotaName) 74 Eventually(session).Should(Exit(0)) 75 }) 76 77 It("deletes the specified quota without prompting", func() { 78 session := helpers.CF("delete-space-quota", quotaName, "-f") 79 Eventually(session).Should(Say(`Deleting space quota %s for org %s as %s\.\.\.`, quotaName, orgName, userName)) 80 Eventually(session).Should(Say("OK")) 81 Eventually(session).Should(Exit(0)) 82 }) 83 }) 84 85 When("the quota name is not provided", func() { 86 It("displays an error and help", func() { 87 session := helpers.CF("delete-space-quota") 88 Eventually(session.Err).Should(Say("Incorrect Usage: the required argument `QUOTA` was not provided")) 89 Eventually(session).Should(Say("USAGE")) 90 Eventually(session).Should(Exit(1)) 91 }) 92 }) 93 94 When("the quota doesn't exist", func() { 95 It("displays a warning and exits 0", func() { 96 session := helpers.CF("delete-space-quota", "-f", "nonexistent-quota") 97 Eventually(session).Should(Say(`Deleting space quota nonexistent-quota for org %s as %s\.\.\.`, orgName, userName)) 98 Eventually(session).Should(Say("OK")) 99 Eventually(session.Err).Should(Say(`Space quota with name 'nonexistent-quota' not found\.`)) 100 Eventually(session).Should(Exit(0)) 101 }) 102 }) 103 }) 104 })