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


Golang Repository.SetRoutingApiEndpoint方法代碼示例

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


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

示例1:

			BeforeEach(func() {
				routingApiServer = ghttp.NewServer()
				routingApiServer.RouteToHandler("GET", "/v1/router_groups",
					func(w http.ResponseWriter, req *http.Request) {
						responseBody := []byte(`[
			{
				  "guid": "bad25cff-9332-48a6-8603-b619858e7992",
					"name": "default-tcp",
					"type": "tcp"
			}]`)
						w.Header().Set("Content-Length", strconv.Itoa(len(responseBody)))
						w.Header().Set("Content-Type", "application/json")
						w.WriteHeader(http.StatusOK)
						w.Write(responseBody)
					})
				configRepo.SetRoutingApiEndpoint(routingApiServer.URL())
			})

			It("lists routing groups", func() {
				cb := func(grp models.RouterGroup) bool {
					Expect(grp).To(Equal(models.RouterGroup{
						Guid: "bad25cff-9332-48a6-8603-b619858e7992",
						Name: "default-tcp",
						Type: "tcp",
					}))
					return true
				}
				err := repo.ListRouterGroups(cb)
				Expect(err).ToNot(HaveOccurred())
			})
		})
開發者ID:0976254669,項目名稱:cli,代碼行數:31,代碼來源:routing_api_test.go

示例2:

			})

			It("prints the domain information", func() {
				cmd.Execute(flagContext)
				Expect(ui.Outputs).To(BeInDisplayOrder(
					[]string{"name", "status", "type"},
					[]string{"Shared-domain1", "shared"},
					[]string{"Private-domain1", "owned"},
				))
			})

			Context("when routing api endpoint is not set", func() {
				var originalRoutingApiEndpoint string
				BeforeEach(func() {
					originalRoutingApiEndpoint = configRepo.RoutingApiEndpoint()
					configRepo.SetRoutingApiEndpoint("")
				})

				AfterEach(func() {
					configRepo.SetRoutingApiEndpoint(originalRoutingApiEndpoint)
				})

				It("does not panic", func() {
					Expect(func() { cmd.Execute(flagContext) }).NotTo(Panic())
				})

				Context("when returned domain has a router-group-guid", func() {
					BeforeEach(func() {
						domainFields = []models.DomainFields{
							models.DomainFields{
								Shared:          true,
開發者ID:chavdarch,項目名稱:cli,代碼行數:31,代碼來源:domains_test.go

示例3:

var _ = Describe("RoutingApi", func() {
	var (
		ui          *testterm.FakeUI
		config      core_config.Repository
		requirement requirements.RoutingAPIRequirement
	)

	BeforeEach(func() {
		ui = new(testterm.FakeUI)
		config = testconfig.NewRepositoryWithAccessToken(core_config.TokenInfo{Username: "my-user"})
		requirement = requirements.NewRoutingAPIRequirement(ui, config)
	})

	Context("when the config has a zero-length RoutingApiEndpoint", func() {
		BeforeEach(func() {
			config.SetRoutingApiEndpoint("")
		})

		It("panics and prints a failure message", func() {
			Expect(func() { requirement.Execute() }).To(Panic())
			Expect(ui.Outputs).To(ContainElement("Routing API URI missing. Please log in again to set the URI automatically."))
		})
	})

	Context("when the config has a RoutingApiEndpoint", func() {
		BeforeEach(func() {
			config.SetRoutingApiEndpoint("api.example.com")
		})

		It("does not print anything", func() {
			requirement.Execute()
開發者ID:vframbach,項目名稱:cli,代碼行數:31,代碼來源:routing_api_test.go


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