Example #1
0
							passedJob, passedResources, passedResourceTypes, passedInputs := factory.CreateArgsForCall(0)
							Expect(passedJob).To(Equal(job))
							Expect(passedResources).To(Equal(resources))
							Expect(passedResourceTypes).To(Equal(resourceTypes))
							Expect(passedInputs).To(ConsistOf(passedInputs))
						})

						Context("when making a plan for the build fails due to an error", func() {
							BeforeEach(func() {
								factory.CreateReturns(atc.Plan{}, errors.New("to err is human"))
							})

							It("marks the build as finished with an errored status and returns nil", func() {
								Expect(fakeBuildsDB.FinishBuildCallCount()).To(Equal(1))

								buildID, status := fakeBuildsDB.FinishBuildArgsForCall(0)
								Expect(buildID).To(Equal(build.ID))
								Expect(status).To(Equal(db.StatusErrored))
							})

							Context("when updating the builds status errors", func() {
								BeforeEach(func() {
									fakeBuildsDB.FinishBuildReturns(errors.New("but to really foul up requires a computer"))
								})

								It("logs and returns nil", func() {
									Expect(engineBuild).To(BeNil())
									Expect(logger).To(gbytes.Say("failed-to-mark-build-as-errored"))
								})
							})
						})