github.com/dcarley/cf-cli@v6.24.1-0.20170220111324-4225ff346898+incompatible/integration/isolated/service_key_command_test.go (about) 1 package isolated 2 3 import ( 4 "fmt" 5 6 . "code.cloudfoundry.org/cli/integration/helpers" 7 . "github.com/onsi/ginkgo" 8 . "github.com/onsi/gomega" 9 . "github.com/onsi/gomega/gbytes" 10 . "github.com/onsi/gomega/gexec" 11 ) 12 13 var _ = Describe("service-key command", func() { 14 var ( 15 org string 16 space string 17 service string 18 servicePlan string 19 serviceInstance string 20 broker ServiceBroker 21 domain string 22 ) 23 24 BeforeEach(func() { 25 org = NewOrgName() 26 space = PrefixedRandomName("SPACE") 27 service = PrefixedRandomName("SERVICE") 28 servicePlan = PrefixedRandomName("SERVICE-PLAN") 29 serviceInstance = PrefixedRandomName("si") 30 31 setupCF(org, space) 32 domain = defaultSharedDomain() 33 }) 34 35 Context("when the service key is not found", func() { 36 BeforeEach(func() { 37 broker = NewServiceBroker(PrefixedRandomName("SERVICE-BROKER"), NewAssets().ServiceBroker, domain, service, servicePlan) 38 broker.Push() 39 broker.Configure() 40 broker.Create() 41 42 Eventually(CF("enable-service-access", service)).Should(Exit(0)) 43 Eventually(CF("create-service", service, servicePlan, serviceInstance)).Should(Exit(0)) 44 }) 45 46 AfterEach(func() { 47 broker.Destroy() 48 }) 49 50 It("outputs an error message and exits 1", func() { 51 session := CF("service-key", serviceInstance, "some-service-key") 52 Eventually(session).Should(Exit(1)) 53 Expect(session.Out).To(Say("FAILED")) 54 Expect(session.Out).To(Say(fmt.Sprintf("No service key some-service-key found for service instance %s", serviceInstance))) 55 }) 56 57 Context("when the --guid option is given", func() { 58 It("outputs nothing and exits 0", func() { 59 session := CF("service-key", serviceInstance, "some-service-key", "--guid") 60 Eventually(session).Should(Exit(0)) 61 Expect(session.Out.Contents()).To(Equal([]byte("\n"))) 62 Expect(session.Err.Contents()).To(BeEmpty()) 63 }) 64 }) 65 }) 66 })