. "github.com/onsi/gomega" ) var _ = Describe("logs with noaa repository", func() { var ( fakeNoaaConsumer *testapi.FakeNoaaConsumer config core_config.ReadWriter fakeTokenRefresher *testapi.FakeAuthenticationRepository repo api.LogsNoaaRepository ) BeforeEach(func() { fakeNoaaConsumer = &testapi.FakeNoaaConsumer{} config = testconfig.NewRepositoryWithDefaults() config.SetLoggregatorEndpoint("loggregator.test.com") config.SetDopplerEndpoint("doppler.test.com") config.SetAccessToken("the-access-token") fakeTokenRefresher = &testapi.FakeAuthenticationRepository{} repo = api.NewLogsNoaaRepository(config, fakeNoaaConsumer, fakeTokenRefresher) }) Describe("RecentLogsFor", func() { It("refreshes token and get metric once more if token has expired.", func() { fakeNoaaConsumer.RecentLogsReturns([]*events.LogMessage{}, noaa_errors.NewUnauthorizedError("Unauthorized token")) repo.RecentLogsFor("app-guid") Ω(fakeTokenRefresher.RefreshTokenCalled).To(BeTrue()) Ω(fakeNoaaConsumer.RecentLogsCallCount()).To(Equal(2)) })