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


Golang TestLogger.Buffer方法代碼示例

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


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

示例1:

						events := []EventHolder{otherEvent, event}

						eventSource.NextStub = func() (models.Event, error) {
							var e EventHolder
							time.Sleep(10 * time.Millisecond)
							if len(events) == 0 {
								return nil, nil
							}
							e, events = events[0], events[1:]
							return e.event, nil
						}
					})

					It("does not call AppCrashed", func() {
						Eventually(ccClient.AppCrashedCallCount).Should(Equal(1))
						buffer := logger.Buffer()
						Expect(buffer).To(Say("process-guid"))
						Expect(buffer).NotTo(Say("other-process-guid"))
					})
				})
			})

			Context("and after < before", func() {
				BeforeEach(func() {
					before.Instance.CrashCount = 1
				})

				It("does not call AppCrashed", func() {
					Consistently(ccClient.AppCrashedCallCount).Should(Equal(0))
				})
			})
開發者ID:emc-xchallenge,項目名稱:tps,代碼行數:31,代碼來源:watcher_test.go

示例2:

		dummyRequest.Header.Add("Authorization", fakePassword)

		fakeResponseWriter = &apifakes.FakeResponseWriter{}
		fakeHandler = &fakes.FakeHandler{}

		logger = lagertest.NewTestLogger("backup-download-test")
		logger.RegisterSink(lager.NewWriterSink(GinkgoWriter, lager.INFO))
	})

	It("should log requests that are prefixed with routePrefix", func() {
		loggerMiddleware := middleware.NewLogger(logger, routePrefix)
		loggerHandler := loggerMiddleware.Wrap(fakeHandler)

		loggerHandler.ServeHTTP(fakeResponseWriter, dummyRequest)

		logContents := logger.Buffer().Contents()
		Expect(logContents).To(ContainSubstring("request"))
		Expect(logContents).To(ContainSubstring("response"))
	})

	It("should not log credentials", func() {
		loggerMiddleware := middleware.NewLogger(logger, routePrefix)
		loggerHandler := loggerMiddleware.Wrap(fakeHandler)

		loggerHandler.ServeHTTP(fakeResponseWriter, dummyRequest)

		logContents := logger.Buffer().Contents()
		Expect(logContents).ToNot(ContainSubstring(fakePassword))
	})

	It("should call next handler", func() {
開發者ID:cautio,項目名稱:switchboard,代碼行數:31,代碼來源:logger_test.go

示例3:

			tcpRouteMapping := db.TcpRouteMapping{
				TcpRoute: db.TcpRoute{
					RouterGroupGuid: DefaultRouterGroupGuid,
					ExternalPort:    5222,
				},
				HostPort: 61000,
				HostIP:   "some-ip-1",
			}
			err := routingApiClient.UpsertTcpRouteMappings([]db.TcpRouteMapping{tcpRouteMapping})
			Expect(err).ToNot(HaveOccurred())

			tcpRouteMappings, err := routingApiClient.TcpRouteMappings()
			Expect(err).NotTo(HaveOccurred())
			Expect(tcpRouteMappings).To(ContainElement(tcpRouteMapping))

			allOutput := logger.Buffer()
			runner := testrunner.New(routerConfigurerPath, routerConfigurerArgs)
			session, err = gexec.Start(runner.Command, allOutput, allOutput)
			Expect(err).ToNot(HaveOccurred())
		})

		AfterEach(func() {
			logger.Info("shutting-down")
			session.Signal(os.Interrupt)
			Eventually(session.Exited, 5*time.Second).Should(BeClosed())
			server.Signal(os.Interrupt)
			Eventually(server.Wait(), 5*time.Second).Should(Receive())
			oauthServer.Close()
		})

		It("syncs with routing api", func() {
開發者ID:jmptrader,項目名稱:cf-tcp-router,代碼行數:31,代碼來源:main_test.go


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