Beispiel #1
0
								aborts := make(chan struct{})
								abort = aborts

								notifier = new(dbfakes.FakeNotifier)
								notifier.NotifyReturns(aborts)

								fakeBuildDB.AbortNotifierReturns(notifier, nil)
							})

							It("listens for aborts", func() {
								Expect(fakeBuildDB.AbortNotifierCallCount()).To(Equal(1))
								Expect(fakeBuildDB.AbortNotifierArgsForCall(0)).To(Equal(model.ID))
							})

							It("resumes the build", func() {
								Expect(realBuild.ResumeCallCount()).To(Equal(1))
							})

							It("breaks the lease", func() {
								Expect(fakeLease.BreakCallCount()).To(Equal(1))
							})

							It("closes the notifier", func() {
								Expect(notifier.CloseCallCount()).To(Equal(1))
							})

							Context("when the build is aborted", func() {
								var errAborted = errors.New("aborted")

								BeforeEach(func() {
									aborted := make(chan error)
Beispiel #2
0
								aborts := make(chan struct{})
								abort = aborts

								notifier = new(dbfakes.FakeNotifier)
								notifier.NotifyReturns(aborts)

								fakeBuildDB.AbortNotifierReturns(notifier, nil)
							})

							It("listens for aborts", func() {
								Ω(fakeBuildDB.AbortNotifierCallCount()).Should(Equal(1))
								Ω(fakeBuildDB.AbortNotifierArgsForCall(0)).Should(Equal(model.ID))
							})

							It("resumes the build", func() {
								Ω(realBuild.ResumeCallCount()).Should(Equal(1))
							})

							It("releases the lock", func() {
								Ω(fakeLock.ReleaseCallCount()).Should(Equal(1))
							})

							It("closes the notifier", func() {
								Ω(notifier.CloseCallCount()).Should(Equal(1))
							})

							Context("when the build is aborted", func() {
								var errAborted = errors.New("aborted")

								BeforeEach(func() {
									aborted := make(chan error)
Beispiel #3
0
					It("creates a one-off build and runs it asynchronously", func() {
						Ω(buildsDB.CreateOneOffBuildCallCount()).Should(Equal(1))

						Ω(fakeEngine.CreateBuildCallCount()).Should(Equal(1))
						oneOff, builtPlan := fakeEngine.CreateBuildArgsForCall(0)
						Ω(oneOff).Should(Equal(db.Build{
							ID:           42,
							Name:         "1",
							JobName:      "job1",
							PipelineName: "some-pipeline",
							Status:       db.StatusStarted,
						}))
						Ω(builtPlan).Should(Equal(plan))

						Ω(fakeBuild.ResumeCallCount()).Should(Equal(1))
					})
				})

				Context("and building fails", func() {
					BeforeEach(func() {
						fakeEngine.CreateBuildReturns(nil, errors.New("oh no!"))
					})

					It("returns 500 Internal Server Error", func() {
						Ω(response.StatusCode).Should(Equal(http.StatusInternalServerError))
					})
				})
			})

			Context("when creating a one-off build fails", func() {