Exemplo n.º 1
0
			It("returns an error", func() {
				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() {
Exemplo n.º 2
0
		factory = &CompositeFetcher{
			LocalFetcher:  fakeLocalFetcher,
			RemoteFetcher: fakeRemoteFetcher,
		}
	})

	Context("when the URL does not contain a scheme", func() {
		It("delegates .Fetch to the local fetcher", func() {
			factory.Fetch(&url.URL{Path: "cake"}, 24)
			Expect(fakeLocalFetcher.FetchCallCount()).To(Equal(1))
			Expect(fakeRemoteFetcher.FetchCallCount()).To(Equal(0))
		})

		It("delegates .FetchID to the local fetcher", func() {
			factory.FetchID(&url.URL{Path: "cake"})
			Expect(fakeLocalFetcher.FetchIDCallCount()).To(Equal(1))
			Expect(fakeRemoteFetcher.FetchIDCallCount()).To(Equal(0))
		})
	})

	Context("when the scheme is docker://", func() {
		It("delegates .Fetch to the remote fetcher", func() {
			factory.Fetch(&url.URL{Scheme: "docker", Path: "cake"}, 24)
			Expect(fakeRemoteFetcher.FetchCallCount()).To(Equal(1))
			Expect(fakeLocalFetcher.FetchCallCount()).To(Equal(0))
		})

		It("delegates .FetchID to the remote fetcher", func() {
			factory.FetchID(&url.URL{Scheme: "docker", Path: "cake"})
			Expect(fakeRemoteFetcher.FetchIDCallCount()).To(Equal(1))
			Expect(fakeLocalFetcher.FetchIDCallCount()).To(Equal(0))