Ejemplo n.º 1
0
		})

		Context("when the job has no inputs", func() {
			BeforeEach(func() {
				job.InputConfigs = []atc.JobInputConfig{}
			})

			It("succeeds", func() {
				err := scheduler.BuildLatestInputs(logger, job, resources)
				Ω(err).ShouldNot(HaveOccurred())
			})

			It("does not try to fetch inputs from the database", func() {
				scheduler.BuildLatestInputs(logger, job, resources)

				Ω(fakePipelineDB.GetLatestInputVersionsCallCount()).Should(BeZero())
			})

			It("does not trigger a build", func() {
				scheduler.BuildLatestInputs(logger, job, resources)

				Ω(fakeEngine.CreateBuildCallCount()).Should(Equal(0))
			})
		})

		Context("when versions are found", func() {
			newInputs := []db.BuildInput{
				{
					Name: "some-input",
					VersionedResource: db.VersionedResource{
						Resource: "some-resource", Version: db.Version{"version": "1"},
Ejemplo n.º 2
0
					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))
				Expect(jobName).To(Equal(job.Name))
				Expect(inputs).To(Equal([]config.JobInput{
					{
						Name:     "some-input",
						Resource: "some-resource",
						Trigger:  true,
						Params:   atc.Params{"some": "params"},
					},
					{
						Name:     "some-other-input",
						Resource: "some-other-resource",
						Trigger:  true,
						Params:   atc.Params{"some": "other-params"},