示例#1
0
			fetcher.StartFetchCycle()

			Eventually(func() int {
				return len(sink.Records())
			}).Should(BeNumerically(">=", 1))

			Expect(sink.Records()).ToNot(BeNil())
			Expect(sink.Records()[0].Message).To(Equal("Unauthorized"))
		})
	})

	Describe(".StartEventCycle", func() {
		Context("when fetching the auth token fails", func() {
			It("logs the failure and tries again", func() {
				tokenFetcher.FetchTokenStub = func() (*token_fetcher.Token, error) {
					return nil, errors.New("failed to get the token")
				}
				fetcher.StartEventCycle()

				Eventually(func() string {
					if len(sink.Records()) > 0 {
						return sink.Records()[0].Message
					} else {
						return ""
					}
				}).Should(Equal("failed to get the token"))
				Eventually(tokenFetcher.FetchTokenCallCount).Should(BeNumerically(">=", 2))
			})
		})

		Context("and the event source successfully subscribes", func() {