本文整理匯總了Golang中cf/models.ServiceBroker.Name方法的典型用法代碼示例。如果您正苦於以下問題:Golang ServiceBroker.Name方法的具體用法?Golang ServiceBroker.Name怎麽用?Golang ServiceBroker.Name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cf/models.ServiceBroker
的用法示例。
在下文中一共展示了ServiceBroker.Name方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: deleteServiceBroker
func deleteServiceBroker(confirmation string, args []string) (ui *testterm.FakeUI, reqFactory *testreq.FakeReqFactory, repo *testapi.FakeServiceBrokerRepo) {
serviceBroker := models.ServiceBroker{}
serviceBroker.Name = "service-broker-to-delete"
serviceBroker.Guid = "service-broker-to-delete-guid"
reqFactory = &testreq.FakeReqFactory{LoginSuccess: true}
repo = &testapi.FakeServiceBrokerRepo{FindByNameServiceBroker: serviceBroker}
ui = &testterm.FakeUI{
Inputs: []string{confirmation},
}
config := testconfig.NewRepositoryWithDefaults()
ctxt := testcmd.NewContext("delete-service-broker", args)
cmd := NewDeleteServiceBroker(ui, config, repo)
testcmd.RunCommand(cmd, ctxt, reqFactory)
return
}
示例2:
Expect(repo.FindByNameName).To(Equal("service-broker-to-delete"))
Expect(repo.DeletedServiceBrokerGuid).To(Equal("service-broker-to-delete-guid"))
Expect(len(ui.Outputs)).To(Equal(2))
testassert.SliceContains(ui.Prompts, testassert.Lines{
{"Really delete", "service-broker-to-delete"},
})
testassert.SliceContains(ui.Outputs, testassert.Lines{
{"Deleting service broker", "service-broker-to-delete", "my-user"},
{"OK"},
})
})
It("TestDeleteWithForceOption", func() {
serviceBroker := models.ServiceBroker{}
serviceBroker.Name = "service-broker-to-delete"
serviceBroker.Guid = "service-broker-to-delete-guid"
reqFactory := &testreq.FakeReqFactory{LoginSuccess: true}
repo := &testapi.FakeServiceBrokerRepo{FindByNameServiceBroker: serviceBroker}
ui := callDeleteServiceBroker([]string{"-f", "service-broker-to-delete"}, reqFactory, repo)
Expect(repo.FindByNameName).To(Equal("service-broker-to-delete"))
Expect(repo.DeletedServiceBrokerGuid).To(Equal("service-broker-to-delete-guid"))
Expect(len(ui.Prompts)).To(Equal(0))
Expect(len(ui.Outputs)).To(Equal(2))
testassert.SliceContains(ui.Outputs, testassert.Lines{
{"Deleting service broker", "service-broker-to-delete", "my-user"},
{"OK"},
})
})
示例3:
repo := &testapi.FakeServiceBrokerRepo{}
args := []string{"arg1", "arg2"}
requirementsFactory.LoginSuccess = false
callRenameServiceBroker(args, requirementsFactory, repo)
Expect(testcmd.CommandDidPassRequirements).To(BeFalse())
requirementsFactory.LoginSuccess = true
callRenameServiceBroker(args, requirementsFactory, repo)
Expect(testcmd.CommandDidPassRequirements).To(BeTrue())
})
It("TestRenameServiceBroker", func() {
requirementsFactory := &testreq.FakeReqFactory{LoginSuccess: true}
broker := models.ServiceBroker{}
broker.Name = "my-found-broker"
broker.Guid = "my-found-broker-guid"
repo := &testapi.FakeServiceBrokerRepo{
FindByNameServiceBroker: broker,
}
args := []string{"my-broker", "my-new-broker"}
ui := callRenameServiceBroker(args, requirementsFactory, repo)
Expect(repo.FindByNameName).To(Equal("my-broker"))
testassert.SliceContains(ui.Outputs, testassert.Lines{
{"Renaming service broker", "my-found-broker", "my-new-broker", "my-user"},
{"OK"},
})
示例4:
}
]
}`
req := testapi.NewCloudControllerTestRequest(testnet.TestRequest{
Method: "GET",
Path: "/v2/service_brokers?q=name%3Amy-broker",
Response: testnet.TestResponse{Status: http.StatusOK, Body: responseBody},
})
ts, handler, repo := createServiceBrokerRepo(req)
defer ts.Close()
foundBroker, apiResponse := repo.FindByName("my-broker")
expectedBroker := models.ServiceBroker{}
expectedBroker.Name = "found-name"
expectedBroker.Url = "http://found.example.com"
expectedBroker.Username = "found-username"
expectedBroker.Password = "found-password"
expectedBroker.Guid = "found-guid"
Expect(handler.AllRequestsCalled()).To(BeTrue())
Expect(apiResponse.IsSuccessful()).To(BeTrue())
Expect(foundBroker).To(Equal(expectedBroker))
})
It("TestFindServiceBrokerByNameWheNotFound", func() {
req := testapi.NewCloudControllerTestRequest(testnet.TestRequest{
Method: "GET",
Path: "/v2/service_brokers?q=name%3Amy-broker",
Response: testnet.TestResponse{Status: http.StatusOK, Body: `{ "resources": [ ] }`},
示例5:
repo := &testapi.FakeServiceBrokerRepo{}
args := []string{"arg1", "arg2", "arg3", "arg4"}
reqFactory.LoginSuccess = false
callUpdateServiceBroker(args, reqFactory, repo)
Expect(testcmd.CommandDidPassRequirements).To(BeFalse())
reqFactory.LoginSuccess = true
callUpdateServiceBroker(args, reqFactory, repo)
Expect(testcmd.CommandDidPassRequirements).To(BeTrue())
})
It("TestUpdateServiceBroker", func() {
reqFactory := &testreq.FakeReqFactory{LoginSuccess: true}
broker := models.ServiceBroker{}
broker.Name = "my-found-broker"
broker.Guid = "my-found-broker-guid"
repo := &testapi.FakeServiceBrokerRepo{
FindByNameServiceBroker: broker,
}
args := []string{"my-broker", "new-username", "new-password", "new-url"}
ui := callUpdateServiceBroker(args, reqFactory, repo)
Expect(repo.FindByNameName).To(Equal("my-broker"))
testassert.SliceContains(ui.Outputs, testassert.Lines{
{"Updating service broker", "my-found-broker", "my-user"},
{"OK"},
})