Пример #1
0
		var lockDir string

		BeforeEach(func() {
			var err error
			lockDir, err = ioutil.TempDir("", "lock-dir")
			Ω(err).ShouldNot(HaveOccurred())
		})

		AfterEach(func() {
			err := os.RemoveAll(lockDir)
			Ω(err).ShouldNot(HaveOccurred())
		})

		Context("when no files exist", func() {
			It("returns an error", func() {
				_, _, err := lockPool.AddUnclaimedLock(lockDir)
				Ω(err).Should(HaveOccurred())
			})
		})

		Context("when a name and metadata file does exist", func() {
			BeforeEach(func() {
				err := ioutil.WriteFile(filepath.Join(lockDir, "name"), []byte("some-lock"), 0755)
				Ω(err).ShouldNot(HaveOccurred())

				err = ioutil.WriteFile(filepath.Join(lockDir, "metadata"), []byte("lock-contents"), 0755)
				Ω(err).ShouldNot(HaveOccurred())
			})

			Context("when setup fails", func() {
				BeforeEach(func() {