Пример #1
0
func (resource ServiceInstancesSummaries) ToModels() (instances []models.ServiceInstance) {
	for _, instanceSummary := range resource.ServiceInstances {
		applicationNames := resource.findApplicationNamesForInstance(instanceSummary.Name)

		planSummary := instanceSummary.ServicePlan
		servicePlan := models.ServicePlanFields{}
		servicePlan.Name = planSummary.Name
		servicePlan.Guid = planSummary.Guid

		offeringSummary := planSummary.ServiceOffering
		serviceOffering := models.ServiceOfferingFields{}
		serviceOffering.Label = offeringSummary.Label
		serviceOffering.Provider = offeringSummary.Provider
		serviceOffering.Version = offeringSummary.Version

		instance := models.ServiceInstance{}
		instance.Name = instanceSummary.Name
		instance.ApplicationNames = applicationNames
		instance.ServicePlan = servicePlan
		instance.ServiceOffering = serviceOffering

		instances = append(instances, instance)
	}

	return
}
Пример #2
0
	It("lists available services", func() {
		plan := models.ServicePlanFields{
			Guid: "spark-guid",
			Name: "spark",
		}

		plan2 := models.ServicePlanFields{
			Guid: "spark-guid-2",
			Name: "spark-2",
		}

		offering := models.ServiceOfferingFields{Label: "cleardb"}

		serviceInstance := models.ServiceInstance{}
		serviceInstance.Name = "my-service-1"
		serviceInstance.ServicePlan = plan
		serviceInstance.ApplicationNames = []string{"cli1", "cli2"}
		serviceInstance.ServiceOffering = offering

		serviceInstance2 := models.ServiceInstance{}
		serviceInstance2.Name = "my-service-2"
		serviceInstance2.ServicePlan = plan2
		serviceInstance2.ApplicationNames = []string{"cli1"}
		serviceInstance2.ServiceOffering = offering

		serviceInstance3 := models.ServiceInstance{}
		serviceInstance3.Name = "my-service-provided-by-user"

		serviceInstances := []models.ServiceInstance{serviceInstance, serviceInstance2, serviceInstance3}
		serviceSummaryRepo := &testapi.FakeServiceSummaryRepo{
			GetSummariesInCurrentSpaceInstances: serviceInstances,
Пример #3
0
		Context("when the service is not user provided", func() {

			BeforeEach(func() {
				setupTestServer(testapi.NewCloudControllerTestRequest(testnet.TestRequest{
					Method:   "PUT",
					Path:     "/v2/service_instances/my-service-instance-guid",
					Matcher:  testnet.RequestBodyMatcher(`{"name":"new-name"}`),
					Response: testnet.TestResponse{Status: http.StatusCreated},
				}))
			})

			It("renames the service", func() {
				serviceInstance := models.ServiceInstance{}
				serviceInstance.Guid = "my-service-instance-guid"
				serviceInstance.ServicePlan = models.ServicePlanFields{
					Guid: "some-plan-guid",
				}

				err := repo.RenameService(serviceInstance, "new-name")
				Expect(testHandler).To(HaveAllRequestsCalled())
				Expect(err).NotTo(HaveOccurred())
			})
		})

		Context("when the service is user provided", func() {
			BeforeEach(func() {
				setupTestServer(testapi.NewCloudControllerTestRequest(testnet.TestRequest{
					Method:   "PUT",
					Path:     "/v2/user_provided_service_instances/my-service-instance-guid",
					Matcher:  testnet.RequestBodyMatcher(`{"name":"new-name"}`),
					Response: testnet.TestResponse{Status: http.StatusCreated},