コード例 #1
0
				Expect(kvpair.Value).To(Equal(lockValue))
			})

			It("destroys the session when the lock is lost", func() {
				ok, _, err := client.KV().Release(&api.KVPair{Key: lockKey, Session: session.ID()}, nil)
				Expect(err).NotTo(HaveOccurred())
				Expect(ok).To(BeTrue())

				Eventually(session.Err()).Should(Receive(Equal(consuladapter.LostLockError(lockKey))))
			})

			Context("when Lock() is stopped (session is destroyed)", func() {
				BeforeEach(func() {
					lock := &fakes.FakeLock{}
					lock.LockReturns(nil, nil)
					sessionMgr.NewLockReturns(lock, nil)
				})

				It("returns an error", func() {
					Expect(lockErr).To(Equal(consuladapter.ErrCancelled))
				})
			})

			Context("when recreating the Session", func() {
				var newSession *consuladapter.Session

				JustBeforeEach(func() {
					var err error
					newSession, err = session.Recreate()
					Expect(err).NotTo(HaveOccurred())
				})