Ejemplo n.º 1
0
					Status: db.StatusPending,
				}

				fakePipelineDB.GetNextPendingBuildReturns(pendingBuild, true, nil)
				buildPrep := db.BuildPreparation{
					Inputs: map[string]db.BuildPreparationStatus{},
				}

				fakeBuildsDB.GetBuildPreparationReturns(buildPrep, true, nil)
				fakePipelineDB.CreateJobBuildReturns(pendingBuild, nil)
				fakePipelineDB.GetNextPendingBuildBySerialGroupReturns(pendingBuild, true, nil)
				fakePipelineDB.UpdateBuildToScheduledReturns(true, nil)
			})

			It("schedules the build", func() {
				Expect(fakePipelineDB.GetNextPendingBuildCallCount()).To(Equal(1))
			})

			It("does not load the versions database, as it was given one", func() {
				Expect(fakePipelineDB.LoadVersionsDBCallCount()).To(Equal(0))
			})
		})

		Context("when a pending build is not found", func() {
			BeforeEach(func() {
				fakePipelineDB.GetNextPendingBuildReturns(db.Build{}, false, nil)
			})

			It("does not start a build", func() {
				scheduler.TryNextPendingBuild(logger, someVersions, job, resources, resourceTypes)
				Expect(fakeEngine.CreateBuildCallCount()).To(Equal(0))