StepFactory: fakeStepFactory, } }) JustBeforeEach(func() { step = conditional.Using(inStep, repo) process = ifrit.Invoke(step) }) itDoesNothing := func() { It("succeeds", func() { Eventually(process.Wait()).Should(Receive(BeNil())) }) It("does not use the step's artifact source", func() { Ω(fakeStepFactory.UsingCallCount()).Should(BeZero()) }) Describe("releasing", func() { It("does not release the input source", func() { Ω(inStep.ReleaseCallCount()).Should(Equal(0)) }) }) Describe("getting the result", func() { It("fails", func() { var success Success Ω(step.Result(&success)).Should(BeFalse()) }) }) }
repo = NewSourceRepository() outStepA = new(fakes.FakeStep) fakeStepA.UsingReturns(outStepA) outStepB = new(fakes.FakeStep) fakeStepB.UsingReturns(outStepB) }) JustBeforeEach(func() { step = aggregate.Using(inStep, repo) process = ifrit.Invoke(step) }) It("uses the input source for all steps", func() { Ω(fakeStepA.UsingCallCount()).Should(Equal(1)) step, repo := fakeStepA.UsingArgsForCall(0) Ω(step).Should(Equal(inStep)) Ω(repo).Should(Equal(repo)) Ω(fakeStepB.UsingCallCount()).Should(Equal(1)) step, repo = fakeStepB.UsingArgsForCall(0) Ω(step).Should(Equal(inStep)) Ω(repo).Should(Equal(repo)) }) It("exits successfully", func() { Eventually(process.Wait()).Should(Receive(BeNil())) }) Describe("executing each source", func() {
close(startB) close(finishB) Eventually(process.Wait()).Should(Receive()) }) Describe("signalling", func() { Context("when the first step is starting", func() { It("forwards the signal to the first step and does not continue", func() { Consistently(process.Ready()).ShouldNot(Receive()) process.Signal(os.Interrupt) Eventually(process.Wait()).Should(Receive(Equal(ErrInterrupted))) Ω(fakeStepFactoryB.UsingCallCount()).Should(BeZero()) }) }) Context("while the first step is running", func() { BeforeEach(func() { startA <- nil }) It("forwards the signal to the first step and does not continue", func() { Consistently(process.Ready()).ShouldNot(BeClosed()) process.Signal(os.Interrupt) Eventually(process.Wait()).Should(Receive(Equal(ErrInterrupted)))
outStep.ResultStub = successResult(false) startStep <- nil finishStep <- nil startSuccess <- nil finishSuccess <- nil startNextStep <- nil finishNextStep <- nil }) It("does not proceed to the next step", func() { Eventually(process.Wait()).Should(Receive(BeNil())) Ω(fakeStepFactorySuccessStep.UsingCallCount()).Should(BeZero()) Ω(fakeStepFactoryNextStep.UsingCallCount()).Should(BeZero()) }) Describe("releasing", func() { It("releases the first source", func() { Eventually(process.Wait()).Should(Receive()) err := step.Release() Ω(err).ShouldNot(HaveOccurred()) Ω(outStep.ReleaseCallCount()).Should(Equal(3)) Ω(successStep.ReleaseCallCount()).Should(BeZero()) Ω(nextStep.ReleaseCallCount()).Should(BeZero()) })
repo = NewSourceRepository() outStepA = new(fakes.FakeStep) fakeStepA.UsingReturns(outStepA) outStepB = new(fakes.FakeStep) fakeStepB.UsingReturns(outStepB) }) JustBeforeEach(func() { step = aggregate.Using(inStep, repo) process = ifrit.Invoke(step) }) It("uses the input source for all steps", func() { Expect(fakeStepA.UsingCallCount()).To(Equal(1)) step, repo := fakeStepA.UsingArgsForCall(0) Expect(step).To(Equal(inStep)) Expect(repo).To(Equal(repo)) Expect(fakeStepB.UsingCallCount()).To(Equal(1)) step, repo = fakeStepB.UsingArgsForCall(0) Expect(step).To(Equal(inStep)) Expect(repo).To(Equal(repo)) }) It("exits successfully", func() { Eventually(process.Wait()).Should(Receive(BeNil())) }) Describe("executing each source", func() {