本文整理匯總了Golang中cf.ServiceBroker類的典型用法代碼示例。如果您正苦於以下問題:Golang ServiceBroker類的具體用法?Golang ServiceBroker怎麽用?Golang ServiceBroker使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ServiceBroker類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: deleteServiceBroker
func deleteServiceBroker(t *testing.T, confirmation string, args []string) (ui *testterm.FakeUI, reqFactory *testreq.FakeReqFactory, repo *testapi.FakeServiceBrokerRepo) {
serviceBroker := cf.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},
}
token, err := testconfig.CreateAccessTokenWithTokenInfo(configuration.TokenInfo{
Username: "my-user",
})
assert.NoError(t, err)
space2 := cf.SpaceFields{}
space2.Name = "my-space"
org2 := cf.OrganizationFields{}
org2.Name = "my-org"
config := &configuration.Configuration{
SpaceFields: space2,
OrganizationFields: org2,
AccessToken: token,
}
ctxt := testcmd.NewContext("delete-service-broker", args)
cmd := NewDeleteServiceBroker(ui, config, repo)
testcmd.RunCommand(cmd, ctxt, reqFactory)
return
}
示例2: TestUpdateServiceBroker
func TestUpdateServiceBroker(t *testing.T) {
reqFactory := &testreq.FakeReqFactory{LoginSuccess: true}
broker := cf.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(t, args, reqFactory, repo)
assert.Equal(t, repo.FindByNameName, "my-broker")
testassert.SliceContains(t, ui.Outputs, testassert.Lines{
{"Updating service broker", "my-found-broker", "my-user"},
{"OK"},
})
expectedServiceBroker := cf.ServiceBroker{}
expectedServiceBroker.Name = "my-found-broker"
expectedServiceBroker.Username = "new-username"
expectedServiceBroker.Password = "new-password"
expectedServiceBroker.Url = "new-url"
expectedServiceBroker.Guid = "my-found-broker-guid"
assert.Equal(t, repo.UpdatedServiceBroker, expectedServiceBroker)
}
示例3: TestDeleteWithForceOption
func TestDeleteWithForceOption(t *testing.T) {
serviceBroker := cf.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(t, []string{"-f", "service-broker-to-delete"}, reqFactory, repo)
assert.Equal(t, repo.FindByNameName, "service-broker-to-delete")
assert.Equal(t, repo.DeletedServiceBrokerGuid, "service-broker-to-delete-guid")
assert.Equal(t, len(ui.Prompts), 0)
assert.Equal(t, len(ui.Outputs), 2)
testassert.SliceContains(t, ui.Outputs, testassert.Lines{
{"Deleting service broker", "service-broker-to-delete", "my-user"},
{"OK"},
})
}
示例4: TestRenameServiceBroker
func TestRenameServiceBroker(t *testing.T) {
reqFactory := &testreq.FakeReqFactory{LoginSuccess: true}
broker := cf.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(t, args, reqFactory, repo)
assert.Equal(t, repo.FindByNameName, "my-broker")
testassert.SliceContains(t, ui.Outputs, testassert.Lines{
{"Renaming service broker", "my-found-broker", "my-new-broker", "my-user"},
{"OK"},
})
assert.Equal(t, repo.RenamedServiceBrokerGuid, "my-found-broker-guid")
assert.Equal(t, repo.RenamedServiceBrokerName, "my-new-broker")
}
示例5: TestFindServiceBrokerByName
func TestFindServiceBrokerByName(t *testing.T) {
responseBody := `{
"resources": [
{
"metadata": {
"guid":"found-guid"
},
"entity": {
"name": "found-name",
"broker_url": "http://found.example.com",
"auth_username": "found-username",
"auth_password": "found-password"
}
}
]
}`
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(t, req)
defer ts.Close()
foundBroker, apiResponse := repo.FindByName("my-broker")
expectedBroker := cf.ServiceBroker{}
expectedBroker.Name = "found-name"
expectedBroker.Url = "http://found.example.com"
expectedBroker.Username = "found-username"
expectedBroker.Password = "found-password"
expectedBroker.Guid = "found-guid"
assert.True(t, handler.AllRequestsCalled())
assert.True(t, apiResponse.IsSuccessful())
assert.Equal(t, foundBroker, expectedBroker)
}
示例6: TestUpdateServiceBroker
func TestUpdateServiceBroker(t *testing.T) {
expectedReqBody := `{"broker_url":"http://update.example.com","auth_username":"update-foouser","auth_password":"update-password"}`
req := testapi.NewCloudControllerTestRequest(testnet.TestRequest{
Method: "PUT",
Path: "/v2/service_brokers/my-guid",
Matcher: testnet.RequestBodyMatcher(expectedReqBody),
Response: testnet.TestResponse{Status: http.StatusOK},
})
ts, handler, repo := createServiceBrokerRepo(t, req)
defer ts.Close()
serviceBroker := cf.ServiceBroker{}
serviceBroker.Guid = "my-guid"
serviceBroker.Name = "foobroker"
serviceBroker.Url = "http://update.example.com"
serviceBroker.Username = "update-foouser"
serviceBroker.Password = "update-password"
apiResponse := repo.Update(serviceBroker)
assert.True(t, handler.AllRequestsCalled())
assert.True(t, apiResponse.IsSuccessful())
}
示例7: TestListServiceBrokers
func TestListServiceBrokers(t *testing.T) {
broker := cf.ServiceBroker{}
broker.Name = "service-broker-to-list-a"
broker.Guid = "service-broker-to-list-guid-a"
broker.Url = "http://service-a-url.com"
broker2 := cf.ServiceBroker{}
broker2.Name = "service-broker-to-list-b"
broker2.Guid = "service-broker-to-list-guid-b"
broker2.Url = "http://service-b-url.com"
broker3 := cf.ServiceBroker{}
broker3.Name = "service-broker-to-list-c"
broker3.Guid = "service-broker-to-list-guid-c"
broker3.Url = "http://service-c-url.com"
serviceBrokers := []cf.ServiceBroker{broker, broker2, broker3}
repo := &testapi.FakeServiceBrokerRepo{
ServiceBrokers: serviceBrokers,
}
ui := callListServiceBrokers(t, []string{}, repo)
testassert.SliceContains(t, ui.Outputs, testassert.Lines{
{"Getting service brokers as", "my-user"},
{"name", "url"},
{"service-broker-to-list-a", "http://service-a-url.com"},
{"service-broker-to-list-b", "http://service-b-url.com"},
{"service-broker-to-list-c", "http://service-c-url.com"},
})
}