JustBeforeEach(func() { err = scheduler.BuildLatestInputs(logger, someVersions, job, resources, resourceTypes) }) Context("loading versions db", func() { BeforeEach(func() { pendingBuild := db.Build{ Status: db.StatusPending, } buildPrep := db.BuildPreparation{ Inputs: map[string]db.BuildPreparationStatus{}, } fakeBuildsDB.GetBuildPreparationReturns(buildPrep, true, nil) fakePipelineDB.CreateJobBuildForCandidateInputsReturns(pendingBuild, true, nil) fakePipelineDB.GetNextPendingBuildReturns(pendingBuild, true, nil) fakePipelineDB.GetNextPendingBuildBySerialGroupReturns(pendingBuild, true, nil) fakePipelineDB.UpdateBuildToScheduledReturns(true, nil) }) It("does not happen", func() { Expect(fakePipelineDB.LoadVersionsDBCallCount()).To(Equal(0)) }) }) It("checks if they are already used for a build", func() { Expect(err).NotTo(HaveOccurred()) Expect(fakePipelineDB.GetLatestInputVersionsCallCount()).To(Equal(1)) versions, jobName, inputs := fakePipelineDB.GetLatestInputVersionsArgsForCall(0) Expect(versions).To(Equal(someVersions))
Context("when creating the build succeeds", func() { BeforeEach(func() { fakePipelineDB.CreateJobBuildForCandidateInputsReturns( db.Build{ ID: 128, Name: "42", }, true, nil, ) fakePipelineDB.GetNextPendingBuildReturns( 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)
Context("when creating the build succeeds", func() { BeforeEach(func() { fakePipelineDB.CreateJobBuildForCandidateInputsReturns( db.Build{ ID: 128, Name: "42", }, true, nil, ) fakePipelineDB.GetNextPendingBuildReturns( db.Build{ ID: 128, Name: "42", }, true, 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)