本文整理汇总了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))
})
})
示例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() {
示例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() {