Ejemplo n.º 1
0
				_, 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())
			Expect(filepath.Join(depotDir, "aardvaark")).To(BeADirectory())
		})

		It("should serialize the a container config to the directory", func() {
			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())
		})
	})
Ejemplo n.º 2
0
				_, 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())
			Expect(filepath.Join(tmpDir, "aardvaark")).To(BeADirectory())
		})

		It("should serialize the a container config to the directory", func() {
			Expect(dirdepot.Create("aardvaark", fakeBundle)).To(Succeed())
			Expect(fakeBundle.SaveCallCount()).To(Equal(1))
			Expect(fakeBundle.SaveArgsForCall(0)).To(Equal(path.Join(tmpDir, "aardvaark")))
		})

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