} }) Context("when the engine build exists", func() { var realBuild *fakes.FakeBuild BeforeEach(func() { fakeBuildDB.GetBuildReturns(model, nil) realBuild = new(fakes.FakeBuild) fakeEngineB.LookupBuildReturns(realBuild, nil) }) Context("when aborting the db build succeeds", func() { BeforeEach(func() { fakeBuildDB.AbortBuildReturns(nil) }) It("succeeds", func() { Ω(abortErr).ShouldNot(HaveOccurred()) }) It("releases the lock", func() { Ω(fakeLock.ReleaseCallCount()).Should(Equal(1)) }) It("aborts the build via the db", func() { Ω(fakeBuildDB.AbortBuildCallCount()).Should(Equal(1)) buildID := fakeBuildDB.AbortBuildArgsForCall(0) Ω(buildID).Should(Equal(model.ID))