当前位置: 首页>>代码示例>>Golang>>正文


Golang TestLogger.LogMessages方法代码示例

本文整理汇总了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))
开发者ID:timani,项目名称:bbs,代码行数:31,代码来源:encryptor_test.go

示例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})
开发者ID:nagyistoce,项目名称:garden-linux,代码行数:31,代码来源:linux_container_test.go

示例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())
		})
开发者ID:pivotal-cf,项目名称:cf-rabbitmq-broker,代码行数:29,代码来源:broker_provisioning_test.go

示例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"))
			})
		})
	})
开发者ID:nagyistoce,项目名称:garden-linux,代码行数:31,代码来源:linux_backend_test.go


注:本文中的github.com/pivotal-golang/lager/lagertest.TestLogger.LogMessages方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。