本文整理匯總了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)
示例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() {
示例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")))
})