github.com/arunkumar7540/cli@v6.45.0+incompatible/integration/shared/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 helpers.SetupCF(org, space) 33 domain = helpers.DefaultSharedDomain() 34 }) 35 36 AfterEach(func() { 37 helpers.QuickDeleteOrg(org) 38 }) 39 40 When("the service key is not found", func() { 41 BeforeEach(func() { 42 broker = helpers.CreateBroker(domain, service, servicePlan) 43 44 Eventually(helpers.CF("enable-service-access", service)).Should(Exit(0)) 45 Eventually(helpers.CF("create-service", service, servicePlan, serviceInstance)).Should(Exit(0)) 46 }) 47 48 AfterEach(func() { 49 broker.Destroy() 50 }) 51 52 It("outputs an error message and exits 1", func() { 53 session := helpers.CF("service-key", serviceInstance, "some-service-key") 54 Eventually(session).Should(Say("FAILED")) 55 Eventually(session).Should(Say(fmt.Sprintf("No service key some-service-key found for service instance %s", serviceInstance))) 56 Eventually(session).Should(Exit(1)) 57 }) 58 59 When("the --guid option is given", func() { 60 It("outputs nothing and exits 0", func() { 61 session := helpers.CF("service-key", serviceInstance, "some-service-key", "--guid") 62 Eventually(session).Should(Exit(0)) 63 Expect(session.Out.Contents()).To(Equal([]byte("\n"))) 64 Expect(session.Err.Contents()).To(BeEmpty()) 65 }) 66 }) 67 }) 68 })