本文整理匯總了Golang中github.com/cloudfoundry/cli/cf/models.ServiceInstance.Guid方法的典型用法代碼示例。如果您正苦於以下問題:Golang ServiceInstance.Guid方法的具體用法?Golang ServiceInstance.Guid怎麽用?Golang ServiceInstance.Guid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry/cli/cf/models.ServiceInstance
的用法示例。
在下文中一共展示了ServiceInstance.Guid方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
var _ = Describe("service-keys command", func() {
var (
ui *testterm.FakeUI
config core_config.Repository
cmd *ServiceKeys
requirementsFactory *testreq.FakeReqFactory
serviceRepo *testapi.FakeServiceRepo
serviceKeyRepo *testapi.FakeServiceKeyRepo
)
BeforeEach(func() {
ui = &testterm.FakeUI{}
config = testconfig.NewRepositoryWithDefaults()
serviceRepo = &testapi.FakeServiceRepo{}
serviceInstance := models.ServiceInstance{}
serviceInstance.Guid = "fake-instance-guid"
serviceRepo.FindInstanceByNameMap = generic.NewMap()
serviceRepo.FindInstanceByNameMap.Set("fake-service-instance", serviceInstance)
serviceKeyRepo = testapi.NewFakeServiceKeyRepo()
cmd = NewListServiceKeys(ui, config, serviceRepo, serviceKeyRepo)
requirementsFactory = &testreq.FakeReqFactory{LoginSuccess: true, TargetedSpaceSuccess: true, ServiceInstanceNotFound: false}
requirementsFactory.ServiceInstance = serviceInstance
})
var callListServiceKeys = func(args []string) bool {
return testcmd.RunCommand(cmd, args, requirementsFactory)
}
Describe("requirements", func() {
It("fails when not logged in", func() {
requirementsFactory = &testreq.FakeReqFactory{LoginSuccess: false}
示例2:
})
})
})
Describe("Delete", func() {
Context("when binding does exist", func() {
var serviceInstance models.ServiceInstance
BeforeEach(func() {
setupTestServer(testapi.NewCloudControllerTestRequest(testnet.TestRequest{
Method: "DELETE",
Path: "/v2/service_bindings/service-binding-2-guid",
Response: testnet.TestResponse{Status: http.StatusOK},
}))
serviceInstance.Guid = "my-service-instance-guid"
binding := models.ServiceBindingFields{}
binding.Url = "/v2/service_bindings/service-binding-1-guid"
binding.AppGuid = "app-1-guid"
binding2 := models.ServiceBindingFields{}
binding2.Url = "/v2/service_bindings/service-binding-2-guid"
binding2.AppGuid = "app-2-guid"
serviceInstance.ServiceBindings = []models.ServiceBindingFields{binding, binding2}
})
It("TestDeleteServiceBinding", func() {
found, apiErr := repo.Delete(serviceInstance, "app-2-guid")
Expect(testHandler).To(testnet.HaveAllRequestsCalled())
Expect(apiErr).NotTo(HaveOccurred())
示例3:
It("fails when a space is not targeted", func() {
requirementsFactory.LoginSuccess = true
Expect(runCommand("okay-this-time-please??")).To(BeFalse())
})
})
Describe("After Requirement", func() {
createServiceInstanceWithState := func(state string) {
offering := models.ServiceOfferingFields{Label: "mysql", DocumentationUrl: "http://documentation.url", Description: "the-description"}
plan := models.ServicePlanFields{Guid: "plan-guid", Name: "plan-name"}
serviceInstance := models.ServiceInstance{}
serviceInstance.Name = "service1"
serviceInstance.Guid = "service1-guid"
serviceInstance.LastOperation.Type = "create"
serviceInstance.LastOperation.State = "in progress"
serviceInstance.LastOperation.Description = "creating resource - step 1"
serviceInstance.ServicePlan = plan
serviceInstance.ServiceOffering = offering
serviceInstance.DashboardUrl = "some-url"
serviceInstance.LastOperation.State = state
serviceInstance.LastOperation.CreatedAt = "created-date"
serviceInstance.LastOperation.UpdatedAt = "updated-date"
requirementsFactory.ServiceInstance = serviceInstance
}
createServiceInstance := func() {
createServiceInstanceWithState("")
}
示例4:
})
It("fails when a space is not targeted", func() {
requirementsFactory.LoginSuccess = true
runCommand("banana", "faaaaasdf")
Expect(testcmd.CommandDidPassRequirements).To(BeFalse())
})
})
Context("when logged in and a space is targeted", func() {
var serviceInstance models.ServiceInstance
BeforeEach(func() {
serviceInstance = models.ServiceInstance{}
serviceInstance.Name = "different-name"
serviceInstance.Guid = "different-name-guid"
requirementsFactory.LoginSuccess = true
requirementsFactory.TargetedSpaceSuccess = true
requirementsFactory.ServiceInstance = serviceInstance
})
It("renames the service, obviously", func() {
runCommand("my-service", "new-name")
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Renaming service", "different-name", "new-name", "my-org", "my-space", "my-user"},
[]string{"OK"},
))
Expect(serviceRepo.RenameServiceServiceInstance).To(Equal(serviceInstance))
示例5:
Expect(testcmd.RunCommand(cmd, []string{"service", "app"}, requirementsFactory)).To(BeFalse())
})
Context("when logged in", func() {
BeforeEach(func() {
requirementsFactory.LoginSuccess = true
})
It("binds a service instance to an app", func() {
app := models.Application{}
app.Name = "my-app"
app.Guid = "my-app-guid"
serviceInstance := models.ServiceInstance{}
serviceInstance.Name = "my-service"
serviceInstance.Guid = "my-service-guid"
requirementsFactory.Application = app
requirementsFactory.ServiceInstance = serviceInstance
serviceBindingRepo := &testapi.FakeServiceBindingRepo{}
ui := callBindService([]string{"my-app", "my-service"}, requirementsFactory, serviceBindingRepo)
Expect(requirementsFactory.ApplicationName).To(Equal("my-app"))
Expect(requirementsFactory.ServiceInstanceName).To(Equal("my-service"))
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"Binding service", "my-service", "my-app", "my-org", "my-space", "my-user"},
[]string{"OK"},
[]string{"TIP", "my-app"},
))
Expect(serviceBindingRepo.CreateServiceInstanceGuid).To(Equal("my-service-guid"))
Expect(serviceBindingRepo.CreateApplicationGuid).To(Equal("my-app-guid"))