Eventually(client.RoutesCallCount, 2*time.Second, 50*time.Millisecond).Should(Equal(2)) }) }) Context("when token fetcher returns error", func() { BeforeEach(func() { uaaClient.FetchTokenReturns(nil, errors.New("Unauthorized")) }) It("logs the error", func() { currentTokenFetchErrors := sender.GetCounter(TokenFetchErrors) Eventually(logger).Should(gbytes.Say("Unauthorized")) Eventually(uaaClient.FetchTokenCallCount).Should(BeNumerically(">=", 2)) Expect(client.SubscribeToEventsWithMaxRetriesCallCount()).Should(Equal(0)) Expect(client.RoutesCallCount()).Should(Equal(0)) Eventually(func() uint64 { return sender.GetCounter(TokenFetchErrors) }).Should(BeNumerically(">", currentTokenFetchErrors)) }) }) Describe("Event cycle", func() { Context("and the event source successfully subscribes", func() { It("responds to events", func() { Eventually(client.SubscribeToEventsWithMaxRetriesCallCount).Should(Equal(1)) eventChannel <- routing_api.Event{ Action: "Delete", Route: db.Route{