Example #1
0
		process := ifrit.Background(ensureStep)

		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() {
		process := ifrit.Background(ensureStep)

		Eventually(step.RunCallCount).Should(Equal(1))
		Eventually(hookFactory.UsingCallCount).Should(Equal(1))

		argsPrev, argsRepo := hookFactory.UsingArgsForCall(0)
		Expect(argsPrev).To(Equal(step))
		Expect(argsRepo).To(Equal(repo))

		Eventually(process.Wait()).Should(Receive(noError()))
	})

	It("runs the ensured hook even if the step errors", func() {
		step.RunReturns(errors.New("disaster"))

		process := ifrit.Background(ensureStep)

		Eventually(step.RunCallCount).Should(Equal(1))
		Eventually(process.Wait()).Should(Receive(errorMatching(ContainSubstring("disaster"))))

		Expect(hook.RunCallCount()).To(Equal(1))
Example #2
0
		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)

		process := ifrit.Background(onSuccessStep)

		Eventually(step.RunCallCount).Should(Equal(1))
		Eventually(successFactory.UsingCallCount).Should(Equal(1))

		argsPrev, argsRepo := successFactory.UsingArgsForCall(0)
		Ω(argsPrev).Should(Equal(step))
		Ω(argsRepo).Should(Equal(repo))

		Eventually(process.Wait()).Should(Receive(noError()))
	})

	It("does not run the success hook if the step errors", func() {
		step.RunReturns(errors.New("disaster"))

		process := ifrit.Background(onSuccessStep)

		Eventually(step.RunCallCount).Should(Equal(1))
		Eventually(process.Wait()).Should(Receive(errorMatching("disaster")))
		Ω(hook.RunCallCount()).Should(Equal(0))
	})
Example #3
0
			It("fails", func() {
				var success Success
				Ω(step.Result(&success)).Should(BeFalse())
			})
		})
	}

	itDoesAThing := func() {
		It("succeeds", func() {
			Eventually(process.Wait()).Should(Receive(BeNil()))
		})

		It("uses the step's artifact source", func() {
			Ω(fakeStepFactory.UsingCallCount()).Should(Equal(1))

			step, repo := fakeStepFactory.UsingArgsForCall(0)
			Ω(step).Should(Equal(inStep))
			Ω(repo).Should(Equal(repo))
		})

		Describe("releasing", func() {
			It("releases the output source", func() {
				err := step.Release()
				Ω(err).ShouldNot(HaveOccurred())

				Ω(outStep.ReleaseCallCount()).Should(Equal(1))
			})

			Context("when releasing the output source fails", func() {
				disaster := errors.New("nope")
Example #4
0
		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)

		process := ifrit.Background(onFailureStep)

		Eventually(step.RunCallCount).Should(Equal(1))
		Eventually(failureFactory.UsingCallCount).Should(Equal(1))

		argsPrev, argsRepo := failureFactory.UsingArgsForCall(0)
		Expect(argsPrev).To(Equal(step))
		Expect(argsRepo).To(Equal(repo))

		Eventually(process.Wait()).Should(Receive(noError()))
	})

	It("does not run the failure hook if the step errors", func() {
		step.RunReturns(errors.New("disaster"))

		process := ifrit.Background(onFailureStep)

		Eventually(step.RunCallCount).Should(Equal(1))
		Eventually(process.Wait()).Should(Receive(errorMatching("disaster")))
		Expect(hook.RunCallCount()).To(Equal(0))
	})
Example #5
0
		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() {
		BeforeEach(func() {
Example #6
0
				AfterEach(func() {
					close(startEnsure)
					close(finishEnsure)
				})

				Context("and the first step finishes successfully", func() {
					BeforeEach(func() {
						startStep <- nil
						finishStep <- nil
					})

					It("executes the success step", func() {
						Eventually(fakeStepFactorySuccessStep.UsingCallCount).Should(Equal(1))
						Eventually(successStep.RunCallCount).Should(Equal(1))
						step, repo = fakeStepFactorySuccessStep.UsingArgsForCall(0)
						Ω(step).Should(Equal(outStep))
						Ω(repo).Should(Equal(repo))

						Eventually(ensureStep.RunCallCount).Should(Equal(0))
					})

					Context("and the success step finishes successfully", func() {
						BeforeEach(func() {
							startSuccess <- nil
							finishSuccess <- nil
						})

						It("executes the ensure step", func() {
							Eventually(fakeStepFactoryEnsureStep.UsingCallCount).Should(Equal(1))
							Eventually(ensureStep.RunCallCount).Should(Equal(1))