コード例 #1
0
ファイル: broker_builder_test.go プロジェクト: fujitsu-cf/cli
		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))
コード例 #2
0
				Label:      "my-service2",
				GUID:       "service-guid2",
				BrokerGUID: "my-service-broker-guid2",
			},
		}

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

		serviceOfferings := models.ServiceOfferings([]models.ServiceOffering{service1, v1Service})
		serviceRepo.FindServiceOfferingsByLabelReturns(serviceOfferings, nil)
		serviceRepo.GetServiceOfferingByGUIDReturns(service1, nil)
		serviceRepo.ListServicesFromBrokerReturns([]models.ServiceOffering{service1}, nil)
		serviceRepo.ListServicesFromManyBrokersReturns([]models.ServiceOffering{service1, service2}, nil)

		plan1 = models.ServicePlanFields{
			Name:                "service-plan1",
			GUID:                "service-plan1-guid",
			ServiceOfferingGUID: "service-guid1",
			OrgNames:            []string{"org1", "org2"},
		}

		plan2 = models.ServicePlanFields{
			Name:                "service-plan2",
			GUID:                "service-plan2-guid",
コード例 #3
0
ファイル: create_service_test.go プロジェクト: fujitsu-cf/cli
		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())
		})