Ejemplo n.º 1
0
		It("grabs a resource checking lock before checking, releases after done", func() {
			Ω(locker.AcquireWriteLockCallCount()).Should(Equal(1))

			lockedInputs := locker.AcquireWriteLockArgsForCall(0)
			Ω(lockedInputs).Should(Equal([]db.NamedLock{db.ResourceCheckingLock("pipeline:some-resource")}))

			Ω(writeLock.ReleaseCallCount()).Should(Equal(1))
		})

		It("releases the resource", func() {
			Ω(fakeResource.ReleaseCallCount()).Should(Equal(1))
		})

		It("clears the resource's check error", func() {
			Ω(fakeRadarDB.SetResourceCheckErrorCallCount()).Should(Equal(1))

			savedResourceArg, err := fakeRadarDB.SetResourceCheckErrorArgsForCall(0)
			Ω(savedResourceArg).Should(Equal(savedResource))
			Ω(err).Should(BeNil())
		})

		Context("when there is no current version", func() {
			It("checks from nil", func() {
				_, version := fakeResource.CheckArgsForCall(0)
				Ω(version).Should(BeNil())
			})
		})

		Context("when there is a current version", func() {
			BeforeEach(func() {
Ejemplo n.º 2
0
				})

				Context("when the interval cannot be parsed", func() {
					BeforeEach(func() {
						resourceConfig.CheckEvery = "bad-value"

						fakeRadarDB.GetConfigReturns(atc.Config{
							Resources: atc.ResourceConfigs{
								resourceConfig,
							},
						}, 1, true, nil)
					})

					It("sets the check error and exits with the error", func() {
						Expect(<-process.Wait()).To(HaveOccurred())
						Expect(fakeRadarDB.SetResourceCheckErrorCallCount()).To(Equal(1))

						resourceName, resourceErr := fakeRadarDB.SetResourceCheckErrorArgsForCall(0)
						Expect(resourceName).To(Equal(savedResource))
						Expect(resourceErr).To(MatchError("time: invalid duration bad-value"))
					})
				})
			})

			It("grabs a periodic resource checking lease before checking, breaks lease after done", func() {
				<-times

				Expect(fakeRadarDB.LeaseResourceCheckingCallCount()).To(Equal(1))

				resourceName, leaseInterval, immediate := fakeRadarDB.LeaseResourceCheckingArgsForCall(0)
				Expect(resourceName).To(Equal("some-resource"))