Esempio n. 1
0
			brokerRepo.FindByNameReturns(serviceBroker1, nil)
			serviceBuilder.GetServicesForBrokerReturns(services, nil)

			broker, err := brokerBuilder.GetBrokerWithAllServices("my-service-broker")
			Expect(err).NotTo(HaveOccurred())
			Expect(broker.Name).To(Equal("my-service-broker"))
			Expect(broker.Services[0].Label).To(Equal("my-public-service"))
			Expect(len(broker.Services[0].Plans)).To(Equal(2))
			Expect(broker.Services[1].Label).To(Equal("my-other-public-service"))
			Expect(len(broker.Services[0].Plans)).To(Equal(2))
		})
	})

	Describe(".GetBrokerWithSpecifiedService", func() {
		It("returns an error if a broker containeing the specific service cannot be found", func() {
			serviceBuilder.GetServiceByNameWithPlansWithOrgNamesReturns(models.ServiceOffering{}, errors.New("Asplosions"))
			_, err := brokerBuilder.GetBrokerWithSpecifiedService("totally-not-a-service")

			Expect(err).To(HaveOccurred())
		})

		It("returns the service broker populated with the specific service", func() {
			serviceBuilder.GetServiceByNameWithPlansWithOrgNamesReturns(service1, nil)
			brokerRepo.FindByGUIDReturns(serviceBroker1, nil)

			broker, err := brokerBuilder.GetBrokerWithSpecifiedService("my-public-service")
			Expect(err).NotTo(HaveOccurred())
			Expect(broker.Name).To(Equal("my-service-broker"))
			Expect(len(broker.Services)).To(Equal(1))
			Expect(broker.Services[0].Label).To(Equal("my-public-service"))
			Expect(len(broker.Services[0].Plans)).To(Equal(2))