コード例 #1
0
ファイル: lease_test.go プロジェクト: pcfdev-forks/atc
				newLease.Break()
			})
		})
	})

	Describe("taking out a lease on resource checking", func() {
		BeforeEach(func() {
			_, err := pipelineDB.GetResource("some-resource")
			Expect(err).NotTo(HaveOccurred())
		})

		Context("when there has been a check recently", func() {
			Context("when acquiring immediately", func() {
				It("gets the lease", func() {
					lease, leased, err := pipelineDB.LeaseResourceChecking("some-resource", 1*time.Second, false)
					Expect(err).NotTo(HaveOccurred())
					Expect(leased).To(BeTrue())

					lease.Break()

					lease, leased, err = pipelineDB.LeaseResourceChecking("some-resource", 1*time.Second, true)
					Expect(err).NotTo(HaveOccurred())
					Expect(leased).To(BeTrue())

					lease.Break()
				})
			})

			Context("when not acquiring immediately", func() {
				It("does not get the lease", func() {