コード例 #1
0
ファイル: on_success_test.go プロジェクト: utako/atc
	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)
コード例 #2
0
ファイル: ensure_test.go プロジェクト: ACPK/atc
	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)
コード例 #3
0
ファイル: on_failure_test.go プロジェクト: ACPK/atc
	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)