Example #1
0
			It("returns nil having only run the first attempt", func() {
				Expect(<-process.Wait()).ToNot(HaveOccurred())

				Expect(attempt1Step.RunCallCount()).To(Equal(1))
				Expect(attempt2Step.RunCallCount()).To(Equal(0))
				Expect(attempt3Step.RunCallCount()).To(Equal(0))
			})

			Describe("Result", func() {
				It("delegates to attempt 1", func() {
					<-process.Wait()

					// internal check for success within retry loop
					Expect(attempt1Step.ResultCallCount()).To(Equal(1))

					attempt1Step.ResultReturns(true)

					var foo interface{}
					destination := &foo
					Expect(step.Result(destination)).To(BeTrue())

					Expect(attempt1Step.ResultCallCount()).To(Equal(2))
					Expect(attempt1Step.ResultArgsForCall(1)).To(Equal(destination))
				})
			})
		})
	})

	Context("when attempt 1 fails, and attempt 2 succeeds", func() {
		BeforeEach(func() {
			attempt1Step.ResultStub = successResult(false)
Example #2
0
			Context("and some branches are not successful", func() {
				BeforeEach(func() {
					outStepA.ResultStub = successResult(true)
					outStepB.ResultStub = successResult(false)
				})

				It("yields false", func() {
					Ω(step.Result(&result)).Should(BeTrue())
					Ω(result).Should(Equal(Success(false)))
				})
			})

			Context("when some branches do not indicate success", func() {
				BeforeEach(func() {
					outStepA.ResultStub = successResult(true)
					outStepB.ResultReturns(false)
				})

				It("only considers the branches that do", func() {
					Ω(step.Result(&result)).Should(BeTrue())
					Ω(result).Should(Equal(Success(true)))
				})
			})

			Context("when no branches indicate success", func() {
				BeforeEach(func() {
					outStepA.ResultReturns(false)
					outStepB.ResultReturns(false)
				})

				It("returns false", func() {
Example #3
0
			})

			itDoesNothing()
		})

		Context("when the input source failed", func() {
			BeforeEach(func() {
				inStep.ResultStub = successResult(false)
			})

			itDoesNothing()
		})

		Context("when the input source cannot indicate success", func() {
			BeforeEach(func() {
				inStep.ResultReturns(false)
			})

			itDoesNothing()
		})
	})

	Context("with a success condition", func() {
		BeforeEach(func() {
			conditional.Conditions = atc.Conditions{atc.ConditionSuccess}
		})

		Context("when the input source is successful", func() {
			BeforeEach(func() {
				inStep.ResultStub = successResult(true)
			})
Example #4
0
							startSuccess <- nil
							finishSuccess <- nil
						})

						It("executes the ensure step", func() {
							Eventually(fakeStepFactoryEnsureStep.UsingCallCount).Should(Equal(1))
							Eventually(ensureStep.RunCallCount).Should(Equal(1))
							step, repo = fakeStepFactoryEnsureStep.UsingArgsForCall(0)
							Ω(step).Should(Equal(outStep))
							Ω(repo).Should(Equal(repo))
						})

						Context("and the ensure step cannot respond to success", func() {

							BeforeEach(func() {
								ensureStep.ResultReturns(false)

								startEnsure <- nil
								finishEnsure <- nil
							})

							It("exits", func() {
								Eventually(process.Wait()).Should(Receive(BeNil()))
							})

							It("does not proceed to the next step", func() {
								Consistently(fakeStepFactoryNextStep.UsingCallCount).Should(BeZero())
							})
						})

						Context("and the ensure step exits with an error", func() {