예제 #1
0
				Expect(ioutil.WriteFile(path.Join(tmp, "a", "test", "file"), []byte(""), 0700)).To(Succeed())

				_, err = fetcher.Fetch(&url.URL{Path: symlinkDir}, 0)
				Expect(err).NotTo(HaveOccurred())
			})
		})

		Context("when the path does not exist", func() {
			It("returns an error", func() {
				_, err := fetcher.Fetch(&url.URL{Path: "does-not-exist"}, 0)
				Expect(err).To(HaveOccurred())
			})

			It("doesn't try to register anything in the graph", func() {
				fetcher.Fetch(&url.URL{Path: "does-not-exist"}, 0)
				Expect(fakeCake.RegisterCallCount()).To(Equal(0))
			})
		})

		Context("when registering fails", func() {
			BeforeEach(func() {
				fakeCake.RegisterStub = func(image *image.Image, layer archive.ArchiveReader) error {
					return errors.New("sold out")
				}
			})

			It("returns a wrapped error", func() {
				_, err := fetcher.Fetch(&url.URL{Path: tmpDir}, 0)
				Expect(err).To(MatchError("repository_fetcher: fetch local rootfs: register rootfs: sold out"))
			})
		})