當前位置: 首頁>>代碼示例>>Golang>>正文


Golang ServiceBroker.Username方法代碼示例

本文整理匯總了Golang中cf.ServiceBroker.Username方法的典型用法代碼示例。如果您正苦於以下問題:Golang ServiceBroker.Username方法的具體用法?Golang ServiceBroker.Username怎麽用?Golang ServiceBroker.Username使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cf.ServiceBroker的用法示例。


在下文中一共展示了ServiceBroker.Username方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: 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)
}
開發者ID:nsnt,項目名稱:cli,代碼行數:28,代碼來源:update_service_broker_test.go

示例2: 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)
}
開發者ID:pmuellr,項目名稱:cli,代碼行數:38,代碼來源:service_brokers_test.go

示例3: 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())
}
開發者ID:pmuellr,項目名稱:cli,代碼行數:24,代碼來源:service_brokers_test.go


注:本文中的cf.ServiceBroker.Username方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。