Exemplo n.º 1
0
				abortErr = build.Abort()
			})

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

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

				Context("when the build is active", func() {
					BeforeEach(func() {
						model.Engine = "fake-engine-b"

						fakeBuildDB.GetBuildReturns(model, nil)

						fakeBuildDB.AbortBuildStub = func(int) error {
							Ω(fakeLocker.AcquireWriteLockImmediatelyCallCount()).Should(Equal(1))

							lockedBuild := fakeLocker.AcquireWriteLockImmediatelyArgsForCall(0)
							Ω(lockedBuild).Should(Equal([]db.NamedLock{db.BuildTrackingLock(model.ID)}))

							Ω(fakeLock.ReleaseCallCount()).Should(BeZero())

							return nil
						}
					})

					Context("when the engine build exists", func() {
						var realBuild *fakes.FakeBuild
Exemplo n.º 2
0
			foundBuild, lookupErr = dbEngine.LookupBuild(logger, build)
		})

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

		It("returns a build", func() {
			Expect(foundBuild).NotTo(BeNil())
		})

		Describe("Abort", func() {
			var abortErr error

			BeforeEach(func() {
				fakeBuildDB.GetBuildReturns(build, true, nil)
			})

			JustBeforeEach(func() {
				abortErr = foundBuild.Abort(lagertest.NewTestLogger("test"))
			})

			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() {