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")) })