Example #1
0
				return nil, nil
			}
		})

		JustBeforeEach(func() {
			process = ifrit.Invoke(radar.Scanner(lagertest.NewTestLogger("test"), "some-resource"))
		})

		AfterEach(func() {
			process.Signal(os.Interrupt)
			<-process.Wait()
		})

		Context("when the lease cannot be acquired", func() {
			BeforeEach(func() {
				fakeRadarDB.LeaseResourceCheckingReturns(nil, false, nil)
			})

			It("does not check", func() {
				Consistently(times).ShouldNot(Receive())
			})
		})

		Context("when the lease can be acquired", func() {
			BeforeEach(func() {
				fakeRadarDB.LeaseResourceCheckingReturns(fakeLease, true, nil)
			})

			It("checks immediately and then on a specified interval", func() {
				Expect(<-times).To(Equal(epoch))