github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/integration/isolated/delete_service_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-service command", func() { 12 Context("when an api is targeted, the user is logged in, and an org and space are targeted", func() { 13 var ( 14 orgName string 15 spaceName string 16 ) 17 18 BeforeEach(func() { 19 orgName = helpers.NewOrgName() 20 spaceName = helpers.NewSpaceName() 21 setupCF(orgName, spaceName) 22 }) 23 24 AfterEach(func() { 25 helpers.QuickDeleteOrg(orgName) 26 }) 27 28 Context("when there is a service instance and it is bound to an app", func() { 29 var ( 30 domain string 31 service string 32 servicePlan string 33 broker helpers.ServiceBroker 34 35 serviceInstanceName string 36 appName string 37 ) 38 39 BeforeEach(func() { 40 domain = defaultSharedDomain() 41 service = helpers.PrefixedRandomName("SERVICE") 42 servicePlan = helpers.PrefixedRandomName("SERVICE-PLAN") 43 broker = helpers.NewServiceBroker(helpers.NewServiceBrokerName(), helpers.NewAssets().ServiceBroker, domain, service, servicePlan) 44 broker.Push() 45 broker.Configure(true) 46 broker.Create() 47 48 Eventually(helpers.CF("enable-service-access", service)).Should(Exit(0)) 49 50 serviceInstanceName = helpers.PrefixedRandomName("SI") 51 Eventually(helpers.CF("create-service", service, servicePlan, serviceInstanceName)).Should(Exit(0)) 52 53 appName = helpers.NewAppName() 54 helpers.WithHelloWorldApp(func(appDir string) { 55 Eventually(helpers.CF("push", appName, "--no-start", "-p", appDir, "-b", "staticfile_buildpack", "--no-route")).Should(Exit(0)) 56 }) 57 58 Eventually(helpers.CF("bind-service", appName, serviceInstanceName)).Should(Exit(0)) 59 }) 60 61 AfterEach(func() { 62 Eventually(helpers.CF("unbind-service", appName, serviceInstanceName)).Should(Exit(0)) 63 Eventually(helpers.CF("delete", appName, "-f")).Should(Exit(0)) 64 Eventually(helpers.CF("delete-service", serviceInstanceName, "-f")).Should(Exit(0)) 65 broker.Destroy() 66 }) 67 68 It("should display an error message that the service instance's keys, bindings, and shares must first be deleted", func() { 69 session := helpers.CF("delete-service", serviceInstanceName, "-f") 70 Eventually(session).Should(Say("Cannot delete service instance. Service keys, bindings, and shares must first be deleted.")) 71 Eventually(session).Should(Exit(1)) 72 }) 73 }) 74 }) 75 })