Expect(len(broker.Services[0].Plans)).To(Equal(2)) Expect(len(broker.Services)).To(Equal(2)) }) }) Describe(".GetAllServiceBrokers", func() { It("returns an error if we cannot list all brokers", func() { brokerRepo.ListServiceBrokersReturns(errors.New("Error finding service brokers")) _, err := brokerBuilder.GetAllServiceBrokers() Expect(err).To(HaveOccurred()) }) It("returns an error if we cannot list the services for a broker", func() { brokerRepo.ListServiceBrokersStub = func(callback func(models.ServiceBroker) bool) error { callback(serviceBroker1) return nil } serviceBuilder.GetServicesForManyBrokersReturns(nil, errors.New("Cannot find services")) _, err := brokerBuilder.GetAllServiceBrokers() Expect(err).To(HaveOccurred()) }) It("returns all service brokers populated with their services", func() { brokerRepo.ListServiceBrokersStub = func(callback func(models.ServiceBroker) bool) error { callback(serviceBroker1) return nil } serviceBuilder.GetServicesForManyBrokersReturns(services, nil)
}) It("lists service brokers", func() { repo.ListServiceBrokersStub = func(callback func(models.ServiceBroker) bool) error { sbs := []models.ServiceBroker{ { Name: "service-broker-to-list-a", Guid: "service-broker-to-list-guid-a", Url: "http://service-a-url.com", }, { Name: "service-broker-to-list-b", Guid: "service-broker-to-list-guid-b", Url: "http://service-b-url.com", }, { Name: "service-broker-to-list-c", Guid: "service-broker-to-list-guid-c", Url: "http://service-c-url.com", }, } for _, sb := range sbs { callback(sb) } return nil } testcmd.RunCliCommand("service-brokers", []string{}, requirementsFactory, updateCommandDependency, false)