Get: "some-get", Resource: "some-resource", }, }, } }) It("returns the correct plan", func() { actual, err := buildFactory.Create(input, resources, resourceTypes, nil) Expect(err).NotTo(HaveOccurred()) expected := expectedPlanFactory.NewPlan(atc.GetPlan{ Type: "git", Name: "some-get", Resource: "some-resource", Pipeline: "some-pipeline", Source: atc.Source{ "uri": "git://some-resource", }, ResourceTypes: resourceTypes, }) Expect(actual).To(testhelpers.MatchPlan(expected)) }) }) Context("with a get for a non-existent resource", func() { BeforeEach(func() { input = atc.JobConfig{ Plan: atc.PlanSequence{ { Get: "some-get", Resource: "not-a-resource",
Task: "second task", Attempts: 3, }, }, }, nil, resourceTypes, nil) Expect(err).NotTo(HaveOccurred()) expected := expectedPlanFactory.NewPlan(atc.RetryPlan{ expectedPlanFactory.NewPlan(atc.TaskPlan{ Name: "second task", Pipeline: "some-pipeline", ResourceTypes: resourceTypes, }), expectedPlanFactory.NewPlan(atc.TaskPlan{ Name: "second task", Pipeline: "some-pipeline", ResourceTypes: resourceTypes, }), expectedPlanFactory.NewPlan(atc.TaskPlan{ Name: "second task", Pipeline: "some-pipeline", ResourceTypes: resourceTypes, }), }) Expect(actual).To(testhelpers.MatchPlan(expected)) }) }) Context("when there is a task annotated with 'attempts' and 'on_success'", func() { It("builds correctly", func() {
BeforeEach(func() { planFactory = atc.NewPlanFactory(123) build = db.Build{ ID: 128, Name: "some-build", } plan = planFactory.NewPlan(atc.TaskPlan{ Config: &atc.TaskConfig{ Image: "some-image", Params: map[string]string{ "FOO": "1", "BAR": "2", }, Run: atc.TaskRunConfig{ Path: "some-script", Args: []string{"arg1", "arg2"}, }, }, }) fakeBuildDB.StartBuildReturns(true, nil) }) JustBeforeEach(func() { createdBuild, buildErr = dbEngine.CreateBuild(logger, build, plan) })
planFactory atc.PlanFactory ) BeforeEach(func() { planFactory = atc.NewPlanFactory(123) fakeDelegate = new(fakes.FakeBuildDelegate) fakeDelegateFactory.DelegateReturns(fakeDelegate) fakeInputDelegate = new(execfakes.FakeGetDelegate) fakeDelegate.InputDelegateReturns(fakeInputDelegate) fakeExecutionDelegate = new(execfakes.FakeTaskDelegate) fakeDelegate.ExecutionDelegateReturns(fakeExecutionDelegate) inputPlan = planFactory.NewPlan(atc.GetPlan{ Name: "some-input", Pipeline: "some-pipeline", }) plan := planFactory.NewPlan(atc.TryPlan{ Step: inputPlan, }) build, err := execEngine.CreateBuild(logger, buildModel, plan) Expect(err).NotTo(HaveOccurred()) build.Resume(logger) }) It("constructs the step correctly", func() { Expect(fakeFactory.GetCallCount()).To(Equal(1)) logger, metadata, sourceName, workerID, workerMetadata, delegate, _, _, _, _, _ := fakeFactory.GetArgsForCall(0) Expect(logger).NotTo(BeNil())
fakeFactory.DependentGetReturns(dependentStepFactory) }) Describe("with a putget in an aggregate", func() { var ( putPlan atc.Plan dependentGetPlan atc.Plan otherPutPlan atc.Plan otherDependentGetPlan atc.Plan ) BeforeEach(func() { putPlan = planFactory.NewPlan(atc.PutPlan{ Name: "some-put", Resource: "some-output-resource", Type: "put", Source: atc.Source{"some": "source"}, Params: atc.Params{"some": "params"}, Pipeline: "some-pipeline", }) dependentGetPlan = planFactory.NewPlan(atc.DependentGetPlan{ Name: "some-get", Resource: "some-input-resource", Type: "get", Source: atc.Source{"some": "source"}, Params: atc.Params{"another": "params"}, Pipeline: "some-pipeline", }) otherPutPlan = planFactory.NewPlan(atc.PutPlan{ Name: "some-put-2", Resource: "some-output-resource-2",
Source: atc.Source{"some": "custom-source"}, }, } }) Context("When there is a task with a timeout", func() { It("builds correctly", func() { actual, err := buildFactory.Create(atc.JobConfig{ Plan: atc.PlanSequence{ { Task: "first task", Timeout: "10s", }, }, }, nil, resourceTypes, nil) Expect(err).NotTo(HaveOccurred()) expected := expectedPlanFactory.NewPlan(atc.TimeoutPlan{ Duration: "10s", Step: expectedPlanFactory.NewPlan(atc.TaskPlan{ Name: "first task", Pipeline: "some-pipeline", ResourceTypes: resourceTypes, }), }) Expect(actual).To(Equal(expected)) }) }) })
It("builds the plan correctly", func() { actual, err := buildFactory.Create(input, resources, resourceTypes, nil) Expect(err).NotTo(HaveOccurred()) expected := expectedPlanFactory.NewPlan(atc.OnFailurePlan{ Step: expectedPlanFactory.NewPlan(atc.DoPlan{ expectedPlanFactory.NewPlan(atc.TaskPlan{ Name: "those who resist our will", Pipeline: "some-pipeline", ResourceTypes: resourceTypes, }), expectedPlanFactory.NewPlan(atc.TaskPlan{ Name: "those who also resist our will", Pipeline: "some-pipeline", ResourceTypes: resourceTypes, }), expectedPlanFactory.NewPlan(atc.TaskPlan{ Name: "third task", Pipeline: "some-pipeline", ResourceTypes: resourceTypes, }), }), Next: expectedPlanFactory.NewPlan(atc.TaskPlan{ Name: "some other failure", Pipeline: "some-pipeline", ResourceTypes: resourceTypes, }), }) Expect(actual).To(testhelpers.MatchPlan(expected)) }) })
}, }, }, }, resources, resourceTypes, nil) Expect(err).NotTo(HaveOccurred()) expected := expectedPlanFactory.NewPlan(atc.DoPlan{ expectedPlanFactory.NewPlan(atc.TaskPlan{ Name: "some thing", Pipeline: "some-pipeline", ResourceTypes: resourceTypes, }), expectedPlanFactory.NewPlan(atc.TaskPlan{ Name: "some thing-2", Pipeline: "some-pipeline", ResourceTypes: resourceTypes, }), expectedPlanFactory.NewPlan(atc.DoPlan{ expectedPlanFactory.NewPlan(atc.TaskPlan{ Name: "some other thing", Pipeline: "some-pipeline", ResourceTypes: resourceTypes, }), }), }) Expect(actual).To(testhelpers.MatchPlan(expected)) }) }) Context("when I have an aggregate inside a do", func() { It("returns the correct plan", func() {
It("returns the correct plan", func() { actual, err := buildFactory.Create(input, resources, resourceTypes, nil) Expect(err).NotTo(HaveOccurred()) expected := expectedPlanFactory.NewPlan(atc.OnSuccessPlan{ Step: expectedPlanFactory.NewPlan(atc.PutPlan{ Type: "git", Name: "some-put", Resource: "some-resource", Pipeline: "some-pipeline", Source: atc.Source{ "uri": "git://some-resource", }, ResourceTypes: resourceTypes, }), Next: expectedPlanFactory.NewPlan(atc.DependentGetPlan{ Type: "git", Name: "some-put", Resource: "some-resource", Pipeline: "some-pipeline", Source: atc.Source{ "uri": "git://some-resource", }, ResourceTypes: resourceTypes, }), }) Expect(actual).To(testhelpers.MatchPlan(expected)) }) }) Context("with a put for a non-existent resource", func() {