本文整理匯總了Golang中cf/models.ServiceInstance.ServicePlan方法的典型用法代碼示例。如果您正苦於以下問題:Golang ServiceInstance.ServicePlan方法的具體用法?Golang ServiceInstance.ServicePlan怎麽用?Golang ServiceInstance.ServicePlan使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cf/models.ServiceInstance
的用法示例。
在下文中一共展示了ServiceInstance.ServicePlan方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ToModels
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:
Expect(userProvidedServiceInstanceRepo.UpdateServiceInstance).NotTo(Equal(serviceInstance))
testassert.SliceContains(ui.Outputs, testassert.Lines{
{"FAILED"},
{"JSON is invalid"},
})
})
It("TestUpdateUserProvidedServiceWithAServiceInstanceThatIsNotUserProvided", func() {
args := []string{"-p", `{"foo":"bar"}`, "service-name"}
plan := models.ServicePlanFields{}
plan.Guid = "my-plan-guid"
serviceInstance := models.ServiceInstance{}
serviceInstance.Name = "found-service-name"
serviceInstance.ServicePlan = plan
reqFactory := &testreq.FakeReqFactory{
LoginSuccess: true,
ServiceInstance: serviceInstance,
}
userProvidedServiceInstanceRepo := &testapi.FakeUserProvidedServiceInstanceRepo{}
ui := callUpdateUserProvidedService(args, reqFactory, userProvidedServiceInstanceRepo)
Expect(userProvidedServiceInstanceRepo.UpdateServiceInstance).NotTo(Equal(serviceInstance))
testassert.SliceContains(ui.Outputs, testassert.Lines{
{"FAILED"},
{"Service Instance is not user provided"},
})
示例3:
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(testnet.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},