コード例 #1
0
		dir, err = ioutil.TempDir("", "path")
		Expect(err).NotTo(HaveOccurred())

		logger = lagertest.NewTestLogger("test")
		threadLocker = &fakes.OSThreadLocker{}
		repo, err = namespace.NewRepository(logger, dir, threadLocker)
		Expect(err).NotTo(HaveOccurred())
	})

	AfterEach(func() {
		os.RemoveAll(dir)
	})

	Describe("PathOf", func() {
		It("returns the full path of a namespace in the repository", func() {
			Expect(repo.PathOf("some-namespace")).To(Equal(filepath.Join(dir, "some-namespace")))
		})
	})

	Describe("Destroy", func() {
		It("removes the namespace bind mount and file and logs the operation", func() {
			ns, err := repo.Create("destroy-ns-test")
			Expect(err).NotTo(HaveOccurred())

			err = repo.Destroy(ns)
			Expect(err).NotTo(HaveOccurred())

			Expect(path.Join(dir, "destroy-ns-test")).NotTo(BeAnExistingFile())
			Expect(logger).To(gbytes.Say("destroy.destroying.*destroy-ns-test"))
		})