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


Golang models.ServiceBroker類代碼示例

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


在下文中一共展示了ServiceBroker類的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
}
開發者ID:knolleary,項目名稱:cli,代碼行數:17,代碼來源:delete_service_broker_test.go

示例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"},
		})
開發者ID:knolleary,項目名稱:cli,代碼行數:30,代碼來源:delete_service_broker_test.go

示例3:

		requirementsFactory := &testreq.FakeReqFactory{}
		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"},
		})
開發者ID:nota-ja,項目名稱:cli,代碼行數:31,代碼來源:rename_service_broker_test.go

示例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",
開發者ID:normalnorman,項目名稱:cli,代碼行數:31,代碼來源:service_brokers_test.go

示例5:

		reqFactory := &testreq.FakeReqFactory{}
		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"},
		})
開發者ID:knolleary,項目名稱:cli,代碼行數:31,代碼來源:update_service_broker_test.go


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