}) }) 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)) }) }) Context("when unclaiming the lock succeeds", func() { BeforeEach(func() { fakeLockHandler.UnclaimLockReturns("some-ref", nil) }) It("tries to broadcast to the lock pool", func() {