var pendingBuild db.Build BeforeEach(func() { pendingBuild = db.Build{ ID: 128, Name: "42", 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() {
Describe("TriggerImmediately", func() { It("creates a build without any specific inputs", func() { _, err := scheduler.TriggerImmediately(logger, job, resources) Ω(err).ShouldNot(HaveOccurred()) Ω(fakePipelineDB.GetLatestInputVersionsCallCount()).Should(Equal(0)) Ω(fakePipelineDB.CreateJobBuildCallCount()).Should(Equal(1)) jobName := fakePipelineDB.CreateJobBuildArgsForCall(0) Ω(jobName).Should(Equal("some-job")) }) Context("when creating the build succeeds", func() { BeforeEach(func() { fakePipelineDB.CreateJobBuildReturns(db.Build{ID: 128, Name: "42"}, nil) }) Context("and it can be scheduled", func() { BeforeEach(func() { fakePipelineDB.ScheduleBuildReturns(true, nil) }) Context("and creating the engine build succeeds", func() { var createdBuild *enginefakes.FakeBuild BeforeEach(func() { createdBuild = new(enginefakes.FakeBuild) fakeEngine.CreateBuildReturns(createdBuild, nil) })
{ Name: "some-input", VersionedResource: db.VersionedResource{ Resource: "some-resource", Version: db.Version{"version": "1"}, }, }, { Name: "some-other-input", VersionedResource: db.VersionedResource{ Resource: "some-other-resource", Version: db.Version{"version": "2"}, }, }, } BeforeEach(func() { fakePipelineDB.CreateJobBuildReturns(createdDBBuild, nil) fakePipelineDB.GetLatestInputVersionsReturns(pendingInputs, true, nil) fakePipelineDB.LoadVersionsDBReturns(someVersions, nil) }) Context("and it can be scheduled", func() { BeforeEach(func() { fakePipelineDB.ScheduleBuildReturns(true, nil) }) Context("and creating the engine build succeeds", func() { var createdBuild *enginefakes.FakeBuild BeforeEach(func() { createdBuild = new(enginefakes.FakeBuild) fakeEngine.CreateBuildReturns(createdBuild, nil)