BeforeEach(func() { stepFactory = &fakes.FakeStepFactory{} successFactory = &fakes.FakeStepFactory{} step = &fakes.FakeStep{} hook = &fakes.FakeStep{} previousStep = &fakes.FakeStep{} stepFactory.UsingReturns(step) successFactory.UsingReturns(hook) repo = exec.NewSourceRepository() onSuccessFactory = exec.OnSuccess(stepFactory, successFactory) onSuccessStep = onSuccessFactory.Using(previousStep, repo) }) It("runs the success hook if the step succeeds", func() { step.ResultStub = successResult(true) process := ifrit.Background(onSuccessStep) Eventually(step.RunCallCount).Should(Equal(1)) Eventually(hook.RunCallCount).Should(Equal(1)) Eventually(process.Wait()).Should(Receive(noError())) }) It("provides the step as the previous step to the hook", func() { step.ResultStub = successResult(true)
BeforeEach(func() { stepFactory = &fakes.FakeStepFactory{} hookFactory = &fakes.FakeStepFactory{} step = &fakes.FakeStep{} hook = &fakes.FakeStep{} previousStep = &fakes.FakeStep{} stepFactory.UsingReturns(step) hookFactory.UsingReturns(hook) repo = exec.NewSourceRepository() ensureFactory = exec.Ensure(stepFactory, hookFactory) ensureStep = ensureFactory.Using(previousStep, repo) }) It("runs the ensure hook if the step succeeds", func() { step.ResultStub = successResult(true) process := ifrit.Background(ensureStep) Eventually(step.RunCallCount).Should(Equal(1)) Eventually(hook.RunCallCount).Should(Equal(1)) Eventually(process.Wait()).Should(Receive(noError())) }) It("runs the ensure hook if the step fails", func() { step.ResultStub = successResult(false)
BeforeEach(func() { stepFactory = &fakes.FakeStepFactory{} failureFactory = &fakes.FakeStepFactory{} step = &fakes.FakeStep{} hook = &fakes.FakeStep{} previousStep = &fakes.FakeStep{} stepFactory.UsingReturns(step) failureFactory.UsingReturns(hook) repo = exec.NewSourceRepository() onFailureFactory = exec.OnFailure(stepFactory, failureFactory) onFailureStep = onFailureFactory.Using(previousStep, repo) }) It("runs the failure hook if step fails", func() { step.ResultStub = successResult(false) process := ifrit.Background(onFailureStep) Eventually(step.RunCallCount).Should(Equal(1)) Eventually(hook.RunCallCount).Should(Equal(1)) Eventually(process.Wait()).Should(Receive(noError())) }) It("provides the step as the previous step to the hook", func() { step.ResultStub = successResult(false)