本文整理汇总了Golang中github.com/pivotal-golang/lager/lagertest.TestLogger.LogMessages方法的典型用法代码示例。如果您正苦于以下问题:Golang TestLogger.LogMessages方法的具体用法?Golang TestLogger.LogMessages怎么用?Golang TestLogger.LogMessages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/pivotal-golang/lager/lagertest.TestLogger
的用法示例。
在下文中一共展示了TestLogger.LogMessages方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
Eventually(fakeDB.SetEncryptionKeyLabelCallCount).Should(Equal(1))
_, newLabel := fakeDB.SetEncryptionKeyLabelArgsForCall(0)
Expect(newLabel).To(Equal("label"))
})
})
Context("when encrypting fails", func() {
BeforeEach(func() {
fakeDB.PerformEncryptionReturns(errors.New("something is broken"))
})
It("does not fail and logs the error", func() {
Eventually(encryptorProcess.Ready()).Should(BeClosed())
Eventually(logger.LogMessages).Should(ContainElement("test.encryptor.encryption-finished"))
Expect(logger.LogMessages()).To(ContainElement("test.encryptor.encryption-failed"))
})
It("does not change the key in the db", func() {
Consistently(fakeDB.SetEncryptionKeyLabelCallCount).Should(Equal(0))
})
})
Context("when fetching the current encryption key fails", func() {
BeforeEach(func() {
fakeDB.EncryptionKeyLabelReturns("", errors.New("can't fetch"))
})
It("fails early", func() {
var err error
Eventually(encryptorProcess.Wait()).Should(Receive(&err))
示例2:
Expect(err).ToNot(HaveOccurred())
info, err := container.Info()
Expect(err).ToNot(HaveOccurred())
Expect(info.MappedPorts).To(Equal([]garden.PortMapping{
{HostPort: 1234, ContainerPort: 5678},
{HostPort: 1235, ContainerPort: 5679},
}))
})
It("should log before and after", func() {
_, err := container.Info()
Expect(err).ToNot(HaveOccurred())
Expect(logger.LogMessages()).To(ContainElement(ContainSubstring("info-starting")))
Expect(logger.LogMessages()).To(ContainElement(ContainSubstring("info-ended")))
})
Context("with running processes", func() {
JustBeforeEach(func() {
p1 := new(wfakes.FakeProcess)
p1.IDReturns("1")
p2 := new(wfakes.FakeProcess)
p2.IDReturns("2")
p3 := new(wfakes.FakeProcess)
p3.IDReturns("3")
fakeProcessTracker.ActiveProcessesReturns([]garden.Process{p1, p2, p3})
示例3:
credentialsGenerator.GenerateReturns(rabbitbroker.Credentials{
Username: "test-user",
Password: "test-password",
})
})
It("returns no error", func() {
_, err := broker.Provision("my-service-id", brokerapi.ProvisionDetails{}, false)
Expect(err).NotTo(HaveOccurred())
})
It("logs a message stating that it is provisioning", func() {
_, err := broker.Provision("my-service-id", brokerapi.ProvisionDetails{}, false)
Expect(err).NotTo(HaveOccurred())
Expect(logger.LogMessages()).To(ContainElement(ContainSubstring("Asked to provision a service: my-service-id")))
})
It("returns a dashboard url", func() {
provisionedSpec, err := broker.Provision("my-service-id", brokerapi.ProvisionDetails{}, false)
Expect(err).NotTo(HaveOccurred())
Expect(provisionedSpec.DashboardURL).To(MatchRegexp(`https://%s/#/login/[a-zA-Z0-9\-]+/[a-zA-Z0-9\-]+`, config.Rabbitmq.ManagementDomain))
})
It("checks whether the host exist", func() {
_, err := broker.Provision("my-service-id", brokerapi.ProvisionDetails{}, false)
Expect(client.GetVhostCallCount()).To(Equal(1))
Expect(client.GetVhostArgsForCall(0)).To(Equal("my-service-id"))
Expect(err).NotTo(HaveOccurred())
})
示例4:
Properties: garden.Properties{"a": "b"},
})
Expect(err).ToNot(HaveOccurred())
_, err = linuxBackend.Create(garden.ContainerSpec{
Handle: "container-2",
Properties: garden.Properties{"a": "b"},
})
Expect(err).ToNot(HaveOccurred())
_, err = linuxBackend.Containers(
garden.Properties{"a": "b"},
)
Expect(err).ToNot(HaveOccurred())
Expect(logger.LogMessages()).To(ConsistOf("test.backend.containers.started", "test.backend.containers.matched", "test.backend.containers.matched", "test.backend.containers.ending"))
logs := logger.Logs()
Expect(logs[3].Data["handles"]).To(ConsistOf("container-1", "container-2"))
})
It("should log the entry and exit when there are no containers", func() {
_, err := linuxBackend.Containers(
garden.Properties{"a": "b", "e": "f"},
)
Expect(err).ToNot(HaveOccurred())
Expect(logger.LogMessages()).To(ConsistOf("test.backend.containers.started", "test.backend.containers.ending"))
})
})
})