}) 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) })
build = db.Build{ ID: 123, } }) JustBeforeEach(func() { engineBuild = scheduler.ScheduleAndResumePendingBuild(logger, someVersions, build, job, resources, resourceTypes, fakeJobService) }) Context("when the lease is aquired", func() { BeforeEach(func() { fakeBuildsDB.LeaseBuildSchedulingReturns(lease, true, nil) }) AfterEach(func() { Expect(lease.BreakCallCount()).To(Equal(1)) }) Context("when build prep can be acquired", func() { var buildPrep db.BuildPreparation BeforeEach(func() { buildPrep = db.BuildPreparation{ BuildID: build.ID, Inputs: map[string]db.BuildPreparationStatus{}, } fakeBuildsDB.GetBuildPreparationReturns(buildPrep, true, nil) }) Context("when build can be scheduled", func() {