BeforeEach(func() { fakeLock = new(dbfakes.FakeLock) fakeLocker.AcquireWriteLockImmediatelyReturns(fakeLock, nil) }) Context("when the build is active", func() { BeforeEach(func() { model.Engine = "fake-engine-b" fakeBuildDB.GetBuildReturns(model, nil) fakeBuildDB.AbortBuildStub = func(int) error { Ω(fakeLocker.AcquireWriteLockImmediatelyCallCount()).Should(Equal(1)) lockedBuild := fakeLocker.AcquireWriteLockImmediatelyArgsForCall(0) Ω(lockedBuild).Should(Equal([]db.NamedLock{db.BuildTrackingLock(model.ID)})) Ω(fakeLock.ReleaseCallCount()).Should(BeZero()) return nil } }) Context("when the engine build exists", func() { var realBuild *fakes.FakeBuild BeforeEach(func() { fakeBuildDB.GetBuildReturns(model, nil) realBuild = new(fakes.FakeBuild) fakeEngineB.LookupBuildReturns(realBuild, nil) })
fakeLease = new(dbfakes.FakeLease) fakeBuildDB.LeaseBuildTrackingReturns(fakeLease, true, nil) }) Context("when the build is active", func() { BeforeEach(func() { model.Engine = "fake-engine-b" fakeBuildDB.GetBuildReturns(model, true, nil) fakeBuildDB.AbortBuildStub = func(int) error { 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()) return nil } }) Context("when the engine build exists", func() { var realBuild *fakes.FakeBuild BeforeEach(func() { fakeBuildDB.GetBuildReturns(model, true, nil) realBuild = new(fakes.FakeBuild) fakeEngineB.LookupBuildReturns(realBuild, nil)