Example #1
0
			})

			Context("when acquiring the lock succeeds", func() {
				var fakeLock *dbfakes.FakeLock

				BeforeEach(func() {
					fakeLock = new(dbfakes.FakeLock)
					fakeLocker.AcquireWriteLockImmediatelyReturns(fakeLock, nil)
				})

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

				It("marks the build as aborted", func() {
					Ω(fakeBuildDB.AbortBuildCallCount()).Should(Equal(1))
					Ω(fakeBuildDB.AbortBuildArgsForCall(0)).Should(Equal(build.ID))
				})
			})
		})
	})

	Describe("Builds", func() {
		var (
			build Build
			model db.Build
		)

		BeforeEach(func() {
			model = db.Build{
				ID: 128,
Example #2
0
			})

			Context("when acquiring the lease succeeds", func() {
				var fakeLease *dbfakes.FakeLease

				BeforeEach(func() {
					fakeLease = new(dbfakes.FakeLease)
					fakeBuildDB.LeaseBuildTrackingReturns(fakeLease, true, nil)
				})

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

				It("marks the build as aborted", func() {
					Expect(fakeBuildDB.AbortBuildCallCount()).To(Equal(1))
					Expect(fakeBuildDB.AbortBuildArgsForCall(0)).To(Equal(build.ID))
				})
			})

			Context("when acquiring the lease fails", func() {
				var fakeLease *dbfakes.FakeLease

				BeforeEach(func() {
					fakeLease = new(dbfakes.FakeLease)
					fakeBuildDB.LeaseBuildTrackingReturns(nil, false, nil)
				})

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