Exemplo n.º 1
0
						fakeBuildDB.GetBuildReturns(model, nil)
					})

					It("succeeds", func() {
						Ω(abortErr).ShouldNot(HaveOccurred())
					})

					It("aborts the build in the db", func() {
						Ω(fakeBuildDB.AbortBuildCallCount()).Should(Equal(1))

						buildID := fakeBuildDB.AbortBuildArgsForCall(0)
						Ω(buildID).Should(Equal(model.ID))
					})

					It("finishes the build in the db so that the aborted event is emitted", func() {
						Ω(fakeBuildDB.FinishBuildCallCount()).Should(Equal(1))

						buildID, status := fakeBuildDB.FinishBuildArgsForCall(0)
						Ω(buildID).Should(Equal(model.ID))
						Ω(status).Should(Equal(db.StatusAborted))
					})

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

			Context("when acquiring the lock fails", func() {
				BeforeEach(func() {
					fakeLocker.AcquireWriteLockImmediatelyReturns(nil, errors.New("no lock for you"))
Exemplo n.º 2
0
						fakeBuildDB.GetBuildReturns(model, true, nil)
					})

					It("succeeds", func() {
						Expect(abortErr).NotTo(HaveOccurred())
					})

					It("aborts the build in the db", func() {
						Expect(fakeBuildDB.AbortBuildCallCount()).To(Equal(1))

						buildID := fakeBuildDB.AbortBuildArgsForCall(0)
						Expect(buildID).To(Equal(model.ID))
					})

					It("finishes the build in the db so that the aborted event is emitted", func() {
						Expect(fakeBuildDB.FinishBuildCallCount()).To(Equal(1))

						buildID, status := fakeBuildDB.FinishBuildArgsForCall(0)
						Expect(buildID).To(Equal(model.ID))
						Expect(status).To(Equal(db.StatusAborted))
					})

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

				Context("when the build is no longer in the database", func() {
					BeforeEach(func() {
						fakeBuildDB.GetBuildReturns(db.Build{}, false, nil)
					})