BeforeEach(func() { 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)