Пример #1
0
					Ω(err).ShouldNot(HaveOccurred())

					Ω(fakePipelineDB.CreateJobBuildForCandidateInputsCallCount()).Should(Equal(0))
				})

				It("does not trigger a build", func() {
					err := scheduler.BuildLatestInputs(logger, job, resources)
					Ω(err).ShouldNot(HaveOccurred())

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

			Context("and they are not used for a build", func() {
				BeforeEach(func() {
					fakePipelineDB.GetJobBuildForInputsReturns(db.Build{}, errors.New("no build"))
				})

				It("creates a build with the found inputs", func() {
					err := scheduler.BuildLatestInputs(logger, job, resources)
					Ω(err).ShouldNot(HaveOccurred())

					Ω(fakePipelineDB.CreateJobBuildForCandidateInputsCallCount()).Should(Equal(1))
					buildJob := fakePipelineDB.CreateJobBuildForCandidateInputsArgsForCall(0)
					Ω(buildJob).Should(Equal("some-job"))
				})

				Context("when creating the build succeeds", func() {
					BeforeEach(func() {
						fakePipelineDB.CreateJobBuildForCandidateInputsReturns(
							db.Build{
Пример #2
0
				})

				It("does not create a build", func() {
					Expect(err).NotTo(HaveOccurred())
					Expect(fakePipelineDB.CreateJobBuildForCandidateInputsCallCount()).To(Equal(0))
				})

				It("does not trigger a build", func() {
					Expect(err).NotTo(HaveOccurred())
					Expect(fakeEngine.CreateBuildCallCount()).To(Equal(0))
				})
			})

			Context("when latest inputs are not already used for a build", func() {
				BeforeEach(func() {
					fakePipelineDB.GetJobBuildForInputsReturns(db.Build{}, false, nil)
				})

				It("creates a build with the found inputs", func() {
					Expect(err).NotTo(HaveOccurred())

					Expect(fakePipelineDB.CreateJobBuildForCandidateInputsCallCount()).To(Equal(1))
					buildJob := fakePipelineDB.CreateJobBuildForCandidateInputsArgsForCall(0)
					Expect(buildJob).To(Equal("some-job"))
				})

				Context("when creating the build fails", func() {
					disaster := errors.New("oh no!")

					BeforeEach(func() {
						fakePipelineDB.CreateJobBuildForCandidateInputsReturns(db.Build{}, false, disaster)