示例#1
0
				Source: atc.Source{"some": "source"},
			}

			params = atc.Params{"some-param": "some-value"}

			version = atc.Version{"some-version": "some-value"}

			tags = []string{"some", "tags"}

			inStep = new(fakes.FakeStep)
			inStep.ResultStub = func(x interface{}) bool {
				switch v := x.(type) {
				case *VersionInfo:
					*v = VersionInfo{
						Version: version,
					}
					return true

				default:
					return false
				}
			}

			repo = NewSourceRepository()
		})

		JustBeforeEach(func() {
			step = factory.DependentGet(sourceName, identifier, getDelegate, resourceConfig, tags, params).Using(inStep, repo)
			process = ifrit.Invoke(step)
		})

		Context("when the tracker can initialize the resource", func() {
示例#2
0
		attempt2Factory = new(fakes.FakeStepFactory)
		attempt2Step = new(fakes.FakeStep)
		attempt2Factory.UsingReturns(attempt2Step)

		attempt3Factory = new(fakes.FakeStepFactory)
		attempt3Step = new(fakes.FakeStep)
		attempt3Factory.UsingReturns(attempt3Step)

		stepFactory = Retry{attempt1Factory, attempt2Factory, attempt3Factory}
		step = stepFactory.Using(nil, nil)
	})

	Context("when attempt 1 succeeds", func() {
		BeforeEach(func() {
			attempt1Step.ResultStub = successResult(true)
		})

		Describe("Run", func() {
			var process ifrit.Process

			JustBeforeEach(func() {
				process = ifrit.Invoke(step)
			})

			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))
示例#3
0
			taskStep        *execfakes.FakeStep

			inputStepFactory *execfakes.FakeStepFactory
			inputStep        *execfakes.FakeStep

			outputStepFactory *execfakes.FakeStepFactory
			outputStep        *execfakes.FakeStep

			dependentStepFactory *execfakes.FakeStepFactory
			dependentStep        *execfakes.FakeStep
		)

		BeforeEach(func() {
			taskStepFactory = new(execfakes.FakeStepFactory)
			taskStep = new(execfakes.FakeStep)
			taskStep.ResultStub = successResult(true)
			taskStepFactory.UsingReturns(taskStep)
			fakeFactory.TaskReturns(taskStepFactory)

			inputStepFactory = new(execfakes.FakeStepFactory)
			inputStep = new(execfakes.FakeStep)
			inputStep.ResultStub = successResult(true)
			inputStepFactory.UsingReturns(inputStep)
			fakeFactory.GetReturns(inputStepFactory)

			outputStepFactory = new(execfakes.FakeStepFactory)
			outputStep = new(execfakes.FakeStep)
			outputStep.ResultStub = successResult(true)
			outputStepFactory.UsingReturns(outputStep)
			fakeFactory.PutReturns(outputStepFactory)
示例#4
0
文件: ensure_test.go 项目: ACPK/atc
		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)

		process := ifrit.Background(ensureStep)

		Eventually(step.RunCallCount).Should(Equal(1))
示例#5
0
		conditional     Conditional

		outStep *fakes.FakeStep

		step    Step
		process ifrit.Process
	)

	BeforeEach(func() {
		inStep = new(fakes.FakeStep)
		repo = NewSourceRepository()

		fakeStepFactory = new(fakes.FakeStepFactory)

		outStep = new(fakes.FakeStep)
		outStep.ResultStub = successResult(true)

		fakeStepFactory.UsingReturns(outStep)

		conditional = Conditional{
			StepFactory: fakeStepFactory,
		}
	})

	JustBeforeEach(func() {
		step = conditional.Using(inStep, repo)
		process = ifrit.Invoke(step)
	})

	itDoesNothing := func() {
		It("succeeds", func() {
示例#6
0
	Describe("Resume", func() {
		Context("get with nil location", func() {
			var (
				getStepFactory *execfakes.FakeStepFactory
				getStep        *execfakes.FakeStep

				fakeDelegate    *fakes.FakeBuildDelegate
				fakeGetDelegate *execfakes.FakeGetDelegate

				plan atc.Plan
			)

			BeforeEach(func() {
				getStepFactory = new(execfakes.FakeStepFactory)
				getStep = new(execfakes.FakeStep)
				getStep.ResultStub = successResult(true)
				getStepFactory.UsingReturns(getStep)
				fakeFactory.GetReturns(getStepFactory)

				fakeDelegate = new(fakes.FakeBuildDelegate)
				fakeDelegateFactory.DelegateReturns(fakeDelegate)

				fakeGetDelegate = new(execfakes.FakeGetDelegate)
				fakeDelegate.InputDelegateReturns(fakeGetDelegate)

				plan = atc.Plan{
					Location: nil,
					Get: &atc.GetPlan{
						Name: "some input",
					},
				}
示例#7
0
			It("returns false", func() {
				result := "this-is-bad"
				Ω(step.Result(&result)).Should(BeFalse())
			})
		})

		Context("when getting a Success result", func() {
			var result Success

			BeforeEach(func() {
				result = false
			})

			Context("and all branches are successful", func() {
				BeforeEach(func() {
					outStepA.ResultStub = successResult(true)
					outStepB.ResultStub = successResult(true)
				})

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

			Context("and some branches are not successful", func() {
				BeforeEach(func() {
					outStepA.ResultStub = successResult(true)
					outStepB.ResultStub = successResult(false)
				})
示例#8
0
		buildModel = db.Build{ID: 84}
	})

	Context("running timeout steps", func() {
		var (
			taskStepFactory *execfakes.FakeStepFactory
			taskStep        *execfakes.FakeStep

			inputStepFactory *execfakes.FakeStepFactory
			inputStep        *execfakes.FakeStep
		)

		BeforeEach(func() {
			taskStepFactory = new(execfakes.FakeStepFactory)
			taskStep = new(execfakes.FakeStep)
			taskStep.ResultStub = successResult(true)
			taskStepFactory.UsingReturns(taskStep)
			fakeFactory.TaskReturns(taskStepFactory)

			inputStepFactory = new(execfakes.FakeStepFactory)
			inputStep = new(execfakes.FakeStep)
			inputStep.ResultStub = successResult(true)
			inputStepFactory.UsingReturns(inputStep)
			fakeFactory.GetReturns(inputStepFactory)
		})

		Context("constructing steps", func() {
			var (
				fakeDelegate      *fakes.FakeBuildDelegate
				fakeInputDelegate *execfakes.FakeGetDelegate
				timeout           string
示例#9
0
		inStep = new(fakes.FakeStep)
		repo = NewSourceRepository()

		outStep = new(fakes.FakeStep)
		fakeStepFactoryStep.UsingReturns(outStep)

		nextStep = new(fakes.FakeStep)
		fakeStepFactoryNextStep.UsingReturns(nextStep)

		startStep = make(chan error, 1)
		finishStep = make(chan error, 1)

		startNextStep = make(chan error, 1)
		finishNextStep = make(chan error, 1)

		outStep.ResultStub = successResult(true)
		outStep.RunStub = func(signals <-chan os.Signal, ready chan<- struct{}) error {
			select {
			case err := <-startStep:
				if err != nil {
					return err
				}
			case <-signals:
				return ErrInterrupted
			}

			close(ready)

			select {
			case <-signals:
				return ErrInterrupted
示例#10
0
			It("assigns the provided interface to Success(true)", func() {
				step.Result(x)
				Expect(*x).Should(Equal(Success(true)))
			})
		})

		Context("when compared against something other than Success", func() {
			const exitCode = 1234

			BeforeEach(func() {
				runStep.ResultStub = func(x interface{}) bool {
					switch v := x.(type) {
					case *ExitStatus:
						*v = ExitStatus(exitCode)
						return true
					default:
						panic("unexpected Result comparison")
					}
				}
			})

			It("deletegates to the inner step", func() {
				x := new(ExitStatus)
				result := step.Result(x)
				Expect(result).Should(Equal(true))
				Expect(*x).Should(Equal(ExitStatus(exitCode)))
			})
		})
	})
示例#11
0
文件: compose_test.go 项目: utako/atc
			It("exits successfully", func() {
				Eventually(process.Wait()).Should(Receive(BeNil()))
			})

			Describe("releasing", func() {
				It("releases both sources", func() {
					Eventually(process.Wait()).Should(Receive(BeNil()))
					step.Release()
					Ω(outStepA.ReleaseCallCount()).Should(Equal(1))
					Ω(outStepB.ReleaseCallCount()).Should(Equal(1))
				})
			})

			Describe("getting the result", func() {
				BeforeEach(func() {
					outStepB.ResultStub = successResult(true)
				})

				It("delegates to the second source", func() {
					Eventually(process.Wait()).Should(Receive(BeNil()))

					var success Success
					Ω(step.Result(&success)).Should(BeTrue())
					Ω(bool(success)).Should(BeTrue())
				})
			})
		})

		Context("and the second source exits with an error", func() {
			disaster := errors.New("nope")