github.com/cloudfoundry-attic/cli-with-i18n@v6.32.1-0.20171002233121-7401370d3b85+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 8 . "github.com/onsi/ginkgo" 9 . "github.com/onsi/gomega" 10 . "github.com/onsi/gomega/gbytes" 11 . "github.com/onsi/gomega/gexec" 12 ) 13 14 var _ = Describe("service-key command", func() { 15 var ( 16 org string 17 space string 18 service string 19 servicePlan string 20 serviceInstance string 21 broker helpers.ServiceBroker 22 domain string 23 ) 24 25 BeforeEach(func() { 26 org = helpers.NewOrgName() 27 space = helpers.NewSpaceName() 28 service = helpers.PrefixedRandomName("SERVICE") 29 servicePlan = helpers.PrefixedRandomName("SERVICE-PLAN") 30 serviceInstance = helpers.PrefixedRandomName("si") 31 32 setupCF(org, space) 33 domain = defaultSharedDomain() 34 }) 35 36 AfterEach(func() { 37 helpers.QuickDeleteOrg(org) 38 }) 39 40 Context("when the service key is not found", func() { 41 BeforeEach(func() { 42 broker = helpers.NewServiceBroker(helpers.NewServiceBrokerName(), helpers.NewAssets().ServiceBroker, domain, service, servicePlan) 43 broker.Push() 44 broker.Configure() 45 broker.Create() 46 47 Eventually(helpers.CF("enable-service-access", service)).Should(Exit(0)) 48 Eventually(helpers.CF("create-service", service, servicePlan, serviceInstance)).Should(Exit(0)) 49 }) 50 51 AfterEach(func() { 52 broker.Destroy() 53 }) 54 55 It("outputs an error message and exits 1", func() { 56 session := helpers.CF("service-key", serviceInstance, "some-service-key") 57 Eventually(session.Out).Should(Say("FAILED")) 58 Eventually(session.Out).Should(Say(fmt.Sprintf("No service key some-service-key found for service instance %s", serviceInstance))) 59 Eventually(session).Should(Exit(1)) 60 }) 61 62 Context("when the --guid option is given", func() { 63 It("outputs nothing and exits 0", func() { 64 session := helpers.CF("service-key", serviceInstance, "some-service-key", "--guid") 65 Eventually(session).Should(Exit(0)) 66 Expect(session.Out.Contents()).To(Equal([]byte("\n"))) 67 Expect(session.Err.Contents()).To(BeEmpty()) 68 }) 69 }) 70 }) 71 })