} else { return "", nil } } }) It("retries", func() { _, err := lockPool.ClaimLock("some-lock") Ω(err).ShouldNot(HaveOccurred()) Ω(fakeLockHandler.ClaimLockCallCount()).Should(Equal(2)) }) }) Context("when claiming a specific lock succeeds", func() { BeforeEach(func() { fakeLockHandler.ClaimLockReturns("some-ref", nil) }) It("tries to broadcast to the lock pool", func() { _, err := lockPool.ClaimLock("some-lock") Ω(err).ShouldNot(HaveOccurred()) Ω(fakeLockHandler.BroadcastLockPoolCallCount()).Should(Equal(1)) }) ValidateSharedBehaviorDuringBroadcastFailures( func() error { _, err := lockPool.ClaimLock("some-lock") return err }, func(expectedNumberOfInteractions int) { Ω(fakeLockHandler.ResetLockCallCount()).Should(Equal(expectedNumberOfInteractions))