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


Golang ReadWriter.SetLoggregatorEndpoint方法代碼示例

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


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

示例1:

			Expect(request.URL.RawQuery).To(Equal("app=my-app-guid"))
			Expect(request.Method).To(Equal("GET"))
			Expect(request.Header.Get("Authorization")).To(ContainSubstring("BEARER my_access_token"))

			for _, msg := range messagesToSend {
				conn.Write(msg)
			}
			time.Sleep(time.Duration(50) * time.Millisecond)
			conn.Close()
		}

		testServer = httptest.NewTLSServer(websocket.Handler(requestHandler.handlerFunc))

		configRepo = testconfig.NewRepositoryWithDefaults()
		configRepo.SetApiEndpoint("https://localhost")
		configRepo.SetLoggregatorEndpoint(strings.Replace(testServer.URL, "https", "wss", 1))

		repo := NewLoggregatorLogsRepository(configRepo)
		logsRepo = &repo
		logsRepo.AddTrustedCerts(testServer.TLS.Certificates)
	})

	AfterEach(func() {
		testServer.Close()
	})

	Describe("RecentLogsFor", func() {
		BeforeEach(func() {
			err := logsRepo.RecentLogsFor("my-app-guid", func() {}, logChan)
			Expect(err).NotTo(HaveOccurred())
			close(logChan)
開發者ID:knolleary,項目名稱:cli,代碼行數:31,代碼來源:logs_test.go

示例2:

	})

	Describe("getting API endpoints from a saved config", func() {
		It("TestGetCloudControllerEndpoint", func() {
			config.SetApiEndpoint("http://api.example.com")

			repo := NewEndpointRepository(config, net.NewCloudControllerGateway())

			endpoint, apiResponse := repo.GetCloudControllerEndpoint()

			Expect(apiResponse.IsSuccessful()).To(BeTrue())
			Expect(endpoint).To(Equal("http://api.example.com"))
		})

		It("TestGetLoggregatorEndpoint", func() {
			config.SetLoggregatorEndpoint("wss://loggregator.example.com:4443")

			repo := NewEndpointRepository(config, net.NewCloudControllerGateway())

			endpoint, apiResponse := repo.GetLoggregatorEndpoint()

			Expect(apiResponse.IsSuccessful()).To(BeTrue())
			Expect(endpoint).To(Equal("wss://loggregator.example.com:4443"))
		})

		Describe("when the loggregator endpoint is not saved in the config (old CC)", func() {
			BeforeEach(func() {
				config.SetLoggregatorEndpoint("")
			})

			It("extrapolates the loggregator URL based on the API URL (SSL API)", func() {
開發者ID:nimbus-cloud,項目名稱:cli,代碼行數:31,代碼來源:endpoints_test.go

示例3:

	testapi "testhelpers/api"
	testconfig "testhelpers/configuration"
	"time"
)

var _ = Describe("loggregator logs repository", func() {
	var (
		fakeConsumer *testapi.FakeLoggregatorConsumer
		logsRepo     *LoggregatorLogsRepository
		configRepo   configuration.ReadWriter
	)

	BeforeEach(func() {
		fakeConsumer = testapi.NewFakeLoggregatorConsumer()
		configRepo = testconfig.NewRepositoryWithDefaults()
		configRepo.SetLoggregatorEndpoint("loggregator-server.test.com")
		configRepo.SetAccessToken("the-access-token")
		repo := NewLoggregatorLogsRepository(configRepo, fakeConsumer)
		logsRepo = &repo
	})

	Describe("RecentLogsFor", func() {
		Context("when an error occurs", func() {
			BeforeEach(func() {
				fakeConsumer.RecentReturns.Err = errors.New("oops")
			})

			It("returns the error", func() {
				_, err := logsRepo.RecentLogsFor("app-guid")
				Expect(err).To(Equal(errors.New("oops")))
			})
開發者ID:nota-ja,項目名稱:cli,代碼行數:31,代碼來源:logs_test.go


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