BrokerGuid: "my-service-broker-guid2",
			},
		}

		v1Service = models.ServiceOffering{
			ServiceOfferingFields: models.ServiceOfferingFields{
				Label:      "v1Service",
				Guid:       "v1Service-guid",
				BrokerGuid: "my-service-broker-guid1",
				Provider:   "IAmV1",
			},
		}

		serviceRepo.FindServiceOfferingsByLabelName = "my-service1"
		serviceRepo.FindServiceOfferingsByLabelServiceOfferings =
			models.ServiceOfferings([]models.ServiceOffering{service1, v1Service})

		serviceRepo.GetServiceOfferingByGuidReturns = struct {
			ServiceOffering models.ServiceOffering
			Error           error
		}{
			service1,
			nil,
		}

		serviceRepo.ListServicesFromBrokerReturns = map[string][]models.ServiceOffering{
			"my-service-broker-guid1": []models.ServiceOffering{service1},
		}

		serviceRepo.ListServicesFromManyBrokersReturns = map[string][]models.ServiceOffering{
			"my-service-broker-guid1,my-service-broker-guid2": []models.ServiceOffering{service1, service2},
Example #2
0
		offering1 = models.ServiceOffering{}
		offering1.Label = "cleardb"
		offering1.Plans = []models.ServicePlanFields{{
			Name: "spark",
			GUID: "cleardb-spark-guid",
			Free: true,
		}, {
			Name: "expensive",
			GUID: "luxury-guid",
			Free: false,
		}}

		offering2 = models.ServiceOffering{}
		offering2.Label = "postgres"

		serviceBuilder.GetServicesByNameForSpaceWithPlansReturns(models.ServiceOfferings([]models.ServiceOffering{offering1, offering2}), nil)
	})

	var callCreateService = func(args []string) bool {
		return testcmd.RunCLICommand("create-service", args, requirementsFactory, updateCommandDependency, false, ui)
	}

	Describe("requirements", func() {
		It("passes when logged in and a space is targeted", func() {
			Expect(callCreateService([]string{"cleardb", "spark", "my-cleardb-service"})).To(BeTrue())
		})

		It("fails when not logged in", func() {
			requirementsFactory.NewLoginRequirementReturns(requirements.Failing{Message: "not logged in"})
			Expect(callCreateService([]string{"cleardb", "spark", "my-cleardb-service"})).To(BeFalse())
		})
Example #3
0
		service3 = models.ServiceOffering{
			ServiceOfferingFields: models.ServiceOfferingFields{
				Label:      "my-other-public-service",
				GUID:       "my-other-public-service-guid",
				BrokerGUID: "my-service-broker-guid",
			},
			Plans: []models.ServicePlanFields{
				publicServicePlan,
				privateServicePlan,
			},
		}

		services = models.ServiceOfferings(
			[]models.ServiceOffering{
				service1,
				service2,
			})

		brokerRepo.FindByGUIDReturns(serviceBroker1, nil)
	})

	Describe(".AttachBrokersToServices", func() {
		It("attaches brokers to an array of services", func() {

			brokers, err := brokerBuilder.AttachBrokersToServices(services)
			Expect(err).NotTo(HaveOccurred())
			Expect(len(brokers)).To(Equal(1))
			Expect(brokers[0].Name).To(Equal("my-service-broker"))
			Expect(brokers[0].Services[0].Label).To(Equal("my-public-service"))
			Expect(len(brokers[0].Services[0].Plans)).To(Equal(2))
				Guid:       "service-guid1",
				BrokerGuid: "my-service-broker-guid1",
			},
		}

		v1Service = models.ServiceOffering{
			ServiceOfferingFields: models.ServiceOfferingFields{
				Label:      "v1Service",
				Guid:       "v1Service-guid",
				BrokerGuid: "my-service-broker-guid1",
				Provider:   "IAmV1",
			},
		}

		serviceRepo.FindServiceOfferingsByLabelName = "my-service1"
		serviceRepo.FindServiceOfferingsByLabelServiceOfferings = models.ServiceOfferings([]models.ServiceOffering{service1, v1Service})

		serviceRepo.GetServiceOfferingByGuidReturns = struct {
			ServiceOffering models.ServiceOffering
			Error           error
		}{
			service1,
			nil,
		}

		serviceRepo.ListServicesFromBrokerReturns = map[string][]models.ServiceOffering{
			"my-service-broker-guid1": []models.ServiceOffering{service1},
		}

		plan1 = models.ServicePlanFields{
			Name:                "service-plan1",