Exemplo n.º 1
0
							realBuild = new(fakes.FakeBuild)
							fakeEngineB.LookupBuildReturns(realBuild, nil)

							realBuild.ResumeStub = func(lager.Logger) {
								Ω(fakeLocker.AcquireWriteLockImmediatelyCallCount()).Should(Equal(1))

								lockedBuild := fakeLocker.AcquireWriteLockImmediatelyArgsForCall(0)
								Ω(lockedBuild).Should(Equal([]db.NamedLock{db.BuildTrackingLock(model.ID)}))

								Ω(fakeLock.ReleaseCallCount()).Should(BeZero())
							}
						})

						Context("when listening for aborts succeeds", func() {
							var (
								notifier *dbfakes.FakeNotifier
								abort    chan<- struct{}
							)

							BeforeEach(func() {
								aborts := make(chan struct{})
								abort = aborts

								notifier = new(dbfakes.FakeNotifier)
								notifier.NotifyReturns(aborts)

								fakeBuildDB.AbortNotifierReturns(notifier, nil)
							})

							It("listens for aborts", func() {
								Ω(fakeBuildDB.AbortNotifierCallCount()).Should(Equal(1))
								Ω(fakeBuildDB.AbortNotifierArgsForCall(0)).Should(Equal(model.ID))
Exemplo n.º 2
0
							fakeEngineB.LookupBuildReturns(realBuild, nil)

							realBuild.ResumeStub = func(lager.Logger) {
								Expect(fakeBuildDB.LeaseBuildTrackingCallCount()).To(Equal(1))

								lockedBuild, interval := fakeBuildDB.LeaseBuildTrackingArgsForCall(0)
								Expect(lockedBuild).To(Equal(model.ID))
								Expect(interval).To(Equal(10 * time.Second))

								Expect(fakeLease.BreakCallCount()).To(BeZero())
							}
						})

						Context("when listening for aborts succeeds", func() {
							var (
								notifier *dbfakes.FakeNotifier
								abort    chan<- struct{}
							)

							BeforeEach(func() {
								aborts := make(chan struct{})
								abort = aborts

								notifier = new(dbfakes.FakeNotifier)
								notifier.NotifyReturns(aborts)

								fakeBuildDB.AbortNotifierReturns(notifier, nil)
							})

							It("listens for aborts", func() {
								Expect(fakeBuildDB.AbortNotifierCallCount()).To(Equal(1))
								Expect(fakeBuildDB.AbortNotifierArgsForCall(0)).To(Equal(model.ID))