Esempio n. 1
0
	. "github.com/onsi/gomega"
)

var _ = Describe("loggregator logs repository", func() {
	var (
		fakeConsumer       *testapi.FakeLoggregatorConsumer
		logsRepo           LogsRepository
		configRepo         configuration.ReadWriter
		fakeTokenRefresher *testapi.FakeAuthenticationRepository
	)

	BeforeEach(func() {
		BufferTime = 1 * time.Millisecond
		fakeConsumer = testapi.NewFakeLoggregatorConsumer()
		configRepo = testconfig.NewRepositoryWithDefaults()
		configRepo.SetLoggregatorEndpoint("loggregator-server.test.com")
		configRepo.SetAccessToken("the-access-token")
		fakeTokenRefresher = &testapi.FakeAuthenticationRepository{}
	})

	JustBeforeEach(func() {
		logsRepo = NewLoggregatorLogsRepository(configRepo, fakeConsumer, fakeTokenRefresher)
	})

	Describe("RecentLogsFor", func() {
		Context("when a LoggregatorConsumer.UnauthorizedError occurs", func() {
			BeforeEach(func() {
				fakeConsumer.RecentReturns.Err = []error{
					loggregator_consumer.NewUnauthorizedError("i'm sorry dave"),
					nil,
				}