Expect(fakeRemoteFetcher.FetchCallCount()).To(Equal(3)) }) It("logs failing attempts", func() { itLogsFailingAttempts(logger, 3, "test.failed-to-fetch") }) }) }) Describe("FetchID failures", func() { Context("when fetching IDs fails twice", func() { BeforeEach(func() { fakeRemoteFetcher.FetchIDStub = func(u *url.URL) (layercake.ID, error) { if fakeRemoteFetcher.FetchIDCallCount() <= 2 { return nil, errors.New("error-talking-to-remote-repo") } else { return nil, nil } } _, err := retryable.FetchID(repoURL) Expect(err).NotTo(HaveOccurred()) }) It("suceeds on third attempt", func() { Expect(fakeRemoteFetcher.FetchIDCallCount()).To(Equal(3)) }) It("logs failing attempts", func() { itLogsFailingAttempts(logger, 2, "test.failed-to-fetch-ID") })