Пример #1
0
					fakeLockHandler.SetupReturns(errors.New("some-error"))
				})

				It("returns an error", func() {
					_, _, err := lockPool.ReleaseLock(lockDir)
					Ω(err).Should(HaveOccurred())
				})
			})

			Context("when setup succeeds", func() {
				It("tries to unclaim the lock it found in the name file", func() {
					_, _, err := lockPool.ReleaseLock(lockDir)
					Ω(err).ShouldNot(HaveOccurred())

					Ω(fakeLockHandler.UnclaimLockCallCount()).Should(Equal(1))
					lockName := fakeLockHandler.UnclaimLockArgsForCall(0)
					Ω(lockName).Should(Equal("some-lock"))
				})

				Context("when unclaiming the lock fails", func() {
					BeforeEach(func() {
						fakeLockHandler.UnclaimLockReturns("", errors.New("disaster"))
					})

					It("returns an error", func() {
						_, _, err := lockPool.ReleaseLock(lockDir)
						Ω(err).Should(HaveOccurred())
						Ω(fakeLockHandler.UnclaimLockCallCount()).Should(Equal(1))
					})
				})