Exemplo n.º 1
0
					BeforeEach(func() {
						fakeLockHandler.ResetLockReturns(errors.New("some-error"))
					})

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

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

						Ω(fakeLockHandler.RemoveLockCallCount()).Should(Equal(1))
						lockName := fakeLockHandler.RemoveLockArgsForCall(0)
						Ω(lockName).Should(Equal("some-remove-lock"))
					})

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

						It("returns an error", func() {
							_, _, err := lockPool.RemoveLock(lockDir)
							Ω(err).Should(HaveOccurred())
							Ω(fakeLockHandler.RemoveLockCallCount()).Should(Equal(1))
						})
					})
Exemplo n.º 2
0
					BeforeEach(func() {
						fakeLockHandler.ResetLockReturns(errors.New("some-error"))
					})

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

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

						Ω(fakeLockHandler.RemoveLockCallCount()).Should(Equal(1))
						lockName := fakeLockHandler.RemoveLockArgsForCall(0)
						Ω(lockName).Should(Equal("some-remove-lock"))
					})

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

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