示例#1
0
			Expect(dirdepot.Create(logger, "aardvaark", fakeBundle)).To(Succeed())
			Expect(fakeBundle.SaveCallCount()).To(Equal(1))
			Expect(fakeBundle.SaveArgsForCall(0)).To(Equal(path.Join(depotDir, "aardvaark")))
		})

		It("destroys the container directory if creation fails", func() {
			fakeBundle.SaveReturns(errors.New("didn't work"))
			Expect(dirdepot.Create(logger, "aardvaark", fakeBundle)).NotTo(Succeed())
			Expect(filepath.Join(depotDir, "aardvaark")).NotTo(BeADirectory())
		})
	})

	Describe("destroy", func() {
		It("should destroy the container directory", func() {
			Expect(os.MkdirAll(filepath.Join(depotDir, "potato"), 0755)).To(Succeed())
			Expect(dirdepot.Destroy(logger, "potato")).To(Succeed())
			Expect(filepath.Join(depotDir, "potato")).NotTo(BeAnExistingFile())
		})

		Context("when the container directory does not exist", func() {
			It("does not error (i.e. the method is idempotent)", func() {
				Expect(dirdepot.Destroy(logger, "potato")).To(Succeed())
			})
		})
	})

	Describe("handles", func() {
		Context("when handles exist", func() {
			BeforeEach(func() {
				Expect(dirdepot.Create(logger, "banana", fakeBundle)).To(Succeed())
				Expect(dirdepot.Create(logger, "banana2", fakeBundle)).To(Succeed())