Context("due to an error", func() { It("logs and returns nil", func() { Expect(err).To(HaveOccurred()) Expect(reason).To(Equal("failed-to-use-inputs-for-build")) }) }) }) It("updates max in flight build prep to be blocking", func() { Expect(fakeDB.UpdateBuildPreparationCallCount()).To(BeNumerically(">=", 6)) Expect(fakeDB.UpdateBuildPreparationArgsForCall(5).MaxRunningBuilds).To(Equal(db.BuildPreparationStatusBlocking)) }) Context("when the job is serial", func() { BeforeEach(func() { jobConfig.Serial = true }) 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 another build with the same job is running", func() {