Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-11-25 17:11:56 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-11-25 17:11:56 +0300
commite1285c1d8ad2c7a5ed556bd5296fbe4afcacb16d (patch)
tree6e1595e7774e1fc8a8782e92e58b0bed20ffc895 /spec
parent94100d4e722ad61fec3e8ab3f9889ffabba1100f (diff)
Restore method that ensures builds being created
Diffstat (limited to 'spec')
-rw-r--r--spec/factories/ci/pipelines.rb11
-rw-r--r--spec/services/ci/process_pipeline_service_spec.rb47
2 files changed, 37 insertions, 21 deletions
diff --git a/spec/factories/ci/pipelines.rb b/spec/factories/ci/pipelines.rb
index ac2a1ba5dff..3c35dae8772 100644
--- a/spec/factories/ci/pipelines.rb
+++ b/spec/factories/ci/pipelines.rb
@@ -29,5 +29,16 @@ FactoryGirl.define do
allow(commit).to receive(:ci_yaml_file) { File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')) }
end
end
+
+ factory(:ci_pipeline_with_yaml) do
+ transient { yaml nil }
+
+ after(:build) do |pipeline, evaluator|
+ raise ArgumentError unless evaluator.yaml
+
+ allow(pipeline).to receive(:ci_yaml_file)
+ .and_return(YAML.dump(evaluator.yaml))
+ end
+ end
end
end
diff --git a/spec/services/ci/process_pipeline_service_spec.rb b/spec/services/ci/process_pipeline_service_spec.rb
index b130f876259..306943a5488 100644
--- a/spec/services/ci/process_pipeline_service_spec.rb
+++ b/spec/services/ci/process_pipeline_service_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
describe Ci::ProcessPipelineService, services: true do
- let(:pipeline) { create(:ci_pipeline, ref: 'master') }
+ let(:pipeline) { create(:ci_empty_pipeline, ref: 'master') }
let(:user) { create(:user) }
describe '#execute' do
@@ -293,57 +293,62 @@ describe Ci::ProcessPipelineService, services: true do
end
end
- context 'when there are builds in multiple stages' do
+ context 'when there are builds that are not created yet' do
+ let(:pipeline) do
+ create(:ci_pipeline_with_yaml, yaml: config)
+ end
+
+ let(:config) do
+ { rspec: { stage: 'test', script: 'rspec' },
+ deploy: { stage: 'deploy', script: 'rsync' } }
+ end
+
before do
create(:ci_build, :created, pipeline: pipeline, name: 'linux', stage: 'build', stage_idx: 0)
create(:ci_build, :created, pipeline: pipeline, name: 'mac', stage: 'build', stage_idx: 0)
- create(:ci_build, :created, pipeline: pipeline, name: 'rspec', stage: 'test', stage_idx: 1)
- create(:ci_build, :created, pipeline: pipeline, name: 'rubocop', stage: 'test', stage_idx: 1)
- create(:ci_build, :created, pipeline: pipeline, name: 'deploy', stage: 'deploy', stage_idx: 2)
end
it 'processes the pipeline' do
# Currently we have five builds with state created
#
expect(builds.count).to eq(0)
- expect(all_builds.count).to eq(5)
+ expect(all_builds.count).to eq(2)
- # Process builds will mark the created as pending
+ # Process builds service will enqueue builds from the first stage.
#
process_pipeline
expect(builds.count).to eq(2)
- expect(all_builds.count).to eq(5)
+ expect(all_builds.count).to eq(2)
- # When builds succeed we will enqueue remaining builds
- # We will have 2 succeeded, 2 pending (from stage test),
- # total 5 (one more build from deploy)
+ # When builds succeed we will enqueue remaining builds.
+ #
+ # We will have 2 succeeded, 1 pending (from stage test), total 4 (two
+ # additional build from `.gitlab-ci.yml`).
#
succeed_pending
process_pipeline
expect(builds.success.count).to eq(2)
- expect(builds.pending.count).to eq(2)
- expect(all_builds.count).to eq(5)
+ expect(builds.pending.count).to eq(1)
+ expect(all_builds.count).to eq(4)
- # When we succeed the 2 pending from stage test,
- # We will queue a deploy stage.
+ # When pending build succeeds in stage test, we enqueue deploy stage.
#
succeed_pending
process_pipeline
expect(builds.pending.count).to eq(1)
- expect(builds.success.count).to eq(4)
- expect(all_builds.count).to eq(5)
+ expect(builds.success.count).to eq(3)
+ expect(all_builds.count).to eq(4)
- # When we succeed last pending build, we will have
- # a total of 5 succeeded builds
+ # When the last one succeeds we have 4 successful builds.
#
succeed_pending
process_pipeline
- expect(builds.success.count).to eq(5)
- expect(all_builds.count).to eq(5)
+ expect(builds.success.count).to eq(4)
+ expect(all_builds.count).to eq(4)
end
end
end