Expect(err).NotTo(HaveOccurred()) logger = lagertest.NewTestLogger("test") fakeBundle = new(fakes.FakeBundleCreator) dirdepot = depot.New(depotDir) }) AfterEach(func() { os.RemoveAll(depotDir) }) Describe("lookup", func() { Context("when a subdirectory with the given name does not exist", func() { It("returns an ErrDoesNotExist", func() { _, err := dirdepot.Lookup(logger, "potato") Expect(err).To(MatchError(depot.ErrDoesNotExist)) }) }) Context("when a subdirectory with the given name exists", func() { It("returns the absolute path of the directory", func() { os.Mkdir(filepath.Join(depotDir, "potato"), 0700) Expect(dirdepot.Lookup(logger, "potato")).To(Equal(filepath.Join(depotDir, "potato"))) }) }) }) Describe("create", func() { It("should create a directory", func() { Expect(dirdepot.Create(logger, "aardvaark", fakeBundle)).To(Succeed())
) BeforeEach(func() { var err error tmpDir, err = ioutil.TempDir("", "depot-test") Expect(err).NotTo(HaveOccurred()) fakeBundle = new(fakes.FakeBundleCreator) dirdepot = depot.New(tmpDir) }) Describe("lookup", func() { Context("when a subdirectory with the given name does not exist", func() { It("returns an ErrDoesNotExist", func() { _, err := dirdepot.Lookup("potato") Expect(err).To(MatchError(depot.ErrDoesNotExist)) }) }) Context("when a subdirectory with the given name exists", func() { It("returns the absolute path of the directory", func() { os.Mkdir(filepath.Join(tmpDir, "potato"), 0700) Expect(dirdepot.Lookup("potato")).To(Equal(filepath.Join(tmpDir, "potato"))) }) }) }) Describe("create", func() { It("should create a directory", func() { Expect(dirdepot.Create("aardvaark", fakeBundle)).To(Succeed())