}) It("marks the build prep max running builds to not blocking", func() { Expect(err).NotTo(HaveOccurred()) Expect(fakeDB.UpdateBuildPreparationCallCount()).To(BeNumerically(">=", 7)) buildPrep = fakeDB.UpdateBuildPreparationArgsForCall(6) Expect(buildPrep.MaxRunningBuilds).To(Equal(db.BuildPreparationStatusNotBlocking)) }) }) }) }) Context("when the job has a max-in-flight of 3", func() { BeforeEach(func() { jobConfig.RawMaxInFlight = 3 }) Context("when the call to get running builds throws an error", func() { BeforeEach(func() { fakeDB.GetRunningBuildsBySerialGroupReturns([]db.Build{}, errors.New("disaster")) }) It("returns the error", func() { Expect(err).To(HaveOccurred()) Expect(reason).To(Equal("db-failed")) Expect(canBuildBeScheduled).To(BeFalse()) }) }) Context("when 1 build is running", func() {