本文整理匯總了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:
)
updateCommandDependency := func(pluginCall bool) {
deps.UI = ui
deps.RepoLocator = deps.RepoLocator.SetServiceRepository(serviceRepo)
deps.RepoLocator = deps.RepoLocator.SetServiceKeyRepository(serviceKeyRepo)
deps.Config = config
commandregistry.Commands.SetCommand(commandregistry.Commands.FindCommand("delete-service-key").SetDependency(deps, pluginCall))
}
BeforeEach(func() {
ui = &testterm.FakeUI{}
config = testconfig.NewRepositoryWithDefaults()
serviceRepo = &apifakes.FakeServiceRepository{}
serviceInstance := models.ServiceInstance{}
serviceInstance.GUID = "fake-service-instance-guid"
serviceRepo.FindInstanceByNameReturns(serviceInstance, nil)
serviceKeyRepo = apifakes.NewFakeServiceKeyRepo()
requirementsFactory = new(requirementsfakes.FakeFactory)
requirementsFactory.NewLoginRequirementReturns(requirements.Passing{})
requirementsFactory.NewTargetedSpaceRequirementReturns(requirements.Passing{})
})
var callDeleteServiceKey = func(args []string) bool {
return testcmd.RunCLICommand("delete-service-key", args, requirementsFactory, updateCommandDependency, false, ui)
}
Describe("requirements are not satisfied", func() {
It("fails when not logged in", func() {
requirementsFactory.NewLoginRequirementReturns(requirements.Failing{Message: "not logged in"})
Expect(callDeleteServiceKey([]string{"fake-service-key-name"})).To(BeFalse())
示例2:
})
})
})
Describe("Delete", func() {
Context("when binding does exist", func() {
var serviceInstance models.ServiceInstance
BeforeEach(func() {
setupTestServer(apifakes.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("deletes the service binding with the given guid", func() {
found, apiErr := repo.Delete(serviceInstance, "app-2-guid")
Expect(testHandler).To(HaveAllRequestsCalled())
Expect(apiErr).NotTo(HaveOccurred())
示例3:
It("fails requirements when not logged in", func() {
Expect(callBindService([]string{"service", "app"})).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
callBindService([]string{"my-app", "my-service"})
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"))
})
示例4:
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("")
}
示例5:
})
It("fails when a space is not targeted", func() {
requirementsFactory.LoginSuccess = true
Expect(runCommand("banana", "faaaaasdf")).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"},
))
actualServiceInstance, actualServiceName := serviceRepo.RenameServiceArgsForCall(0)