Example #1
0
			Eventually(logger).Should(gbytes.Say("test.watcher.failed-getting-next-tcp-routing-event"))
		})
	})

	Context("when subscribe to events fails", func() {
		var (
			routingApiErrChannel chan error
		)
		BeforeEach(func() {
			routingApiErrChannel = make(chan error)

			routingApiClient.SubscribeToTcpEventsStub = func() (routing_api.TcpEventSource, error) {
				select {
				case err := <-routingApiErrChannel:
					if err != nil {
						return nil, err
					}
				}
				return eventSource, nil
			}

			testWatcher = watcher.New(routingApiClient, updater, tokenFetcher, 1, syncChannel, logger)
		})

		JustBeforeEach(func() {
			routingApiErrChannel <- errors.New("kaboom")
		})

		It("retries to subscribe", func() {
			close(routingApiErrChannel)
			Eventually(routingApiClient.SubscribeToTcpEventsCallCount, 5*time.Second, 1*time.Second).Should(Equal(2))