diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2019-08-16 14:47:05 +0000 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2019-08-16 14:47:05 +0000 |
commit | 535c2d3c71c1cc623958a48f429a88ecaafb2702 (patch) | |
tree | 508aa3b90978951b1f8470ac3d7d2101ec64e56a /spec | |
parent | 94c7a93dcae1a0e865d11df00ac24add676b636b (diff) | |
parent | 16084ee9d3fdfc333a113e4cbcd3f6d2fc402628 (diff) | |
download | gitlab-ce-535c2d3c71c1cc623958a48f429a88ecaafb2702.tar.gz |
Merge branch 'mc/feature/pipeline-tracking-config-ce' into 'master'
Add `needs:` CI config option CE
Closes gitlab-ee#12334
See merge request gitlab-org/gitlab-ce!31346
Diffstat (limited to 'spec')
-rw-r--r-- | spec/factories/ci/bridge.rb | 9 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/pipeline/seed/build_spec.rb | 24 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/yaml_processor_spec.rb | 5 | ||||
-rw-r--r-- | spec/models/ci/bridge_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/ci/pipeline_spec.rb | 7 |
5 files changed, 40 insertions, 7 deletions
diff --git a/spec/factories/ci/bridge.rb b/spec/factories/ci/bridge.rb index 6491b9dca19..b1b714277e4 100644 --- a/spec/factories/ci/bridge.rb +++ b/spec/factories/ci/bridge.rb @@ -8,7 +8,7 @@ FactoryBot.define do ref 'master' tag false created_at 'Di 29. Okt 09:50:00 CET 2013' - status :success + status :created pipeline factory: :ci_pipeline @@ -17,6 +17,7 @@ FactoryBot.define do end transient { downstream nil } + transient { upstream nil } after(:build) do |bridge, evaluator| bridge.project ||= bridge.pipeline.project @@ -26,6 +27,12 @@ FactoryBot.define do trigger: { project: evaluator.downstream.full_path } ) end + + if evaluator.upstream.present? + bridge.options = bridge.options.to_h.merge( + bridge_needs: { pipeline: evaluator.upstream.full_path } + ) + end end end end diff --git a/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb b/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb index 5d4dec5899a..1a9350d68bd 100644 --- a/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb @@ -20,20 +20,36 @@ describe Gitlab::Ci::Pipeline::Seed::Build do describe '#bridge?' do subject { seed_build.bridge? } - context 'when job is a bridge' do + context 'when job is a downstream bridge' do let(:attributes) do { name: 'rspec', ref: 'master', options: { trigger: 'my/project' } } end it { is_expected.to be_truthy } + + context 'when trigger definition is empty' do + let(:attributes) do + { name: 'rspec', ref: 'master', options: { trigger: '' } } + end + + it { is_expected.to be_falsey } + end end - context 'when trigger definition is empty' do + context 'when job is an upstream bridge' do let(:attributes) do - { name: 'rspec', ref: 'master', options: { trigger: '' } } + { name: 'rspec', ref: 'master', options: { bridge_needs: { pipeline: 'my/project' } } } end - it { is_expected.to be_falsey } + it { is_expected.to be_truthy } + + context 'when upstream definition is empty' do + let(:attributes) do + { name: 'rspec', ref: 'master', options: { bridge_needs: { pipeline: '' } } } + end + + it { is_expected.to be_falsey } + end end context 'when job is not a bridge' do diff --git a/spec/lib/gitlab/ci/yaml_processor_spec.rb b/spec/lib/gitlab/ci/yaml_processor_spec.rb index 4ffa1fc9fd8..d5567b4f166 100644 --- a/spec/lib/gitlab/ci/yaml_processor_spec.rb +++ b/spec/lib/gitlab/ci/yaml_processor_spec.rb @@ -1153,7 +1153,10 @@ module Gitlab stage_idx: 1, name: "test1", options: { - script: ["test"] + script: ["test"], + # This does not make sense, there is a follow-up: + # https://gitlab.com/gitlab-org/gitlab-ce/issues/65569 + bridge_needs: %w[build1 build2] }, needs_attributes: [ { name: "build1" }, diff --git a/spec/models/ci/bridge_spec.rb b/spec/models/ci/bridge_spec.rb index eb32198265b..a871f9b3fe6 100644 --- a/spec/models/ci/bridge_spec.rb +++ b/spec/models/ci/bridge_spec.rb @@ -23,7 +23,7 @@ describe Ci::Bridge do let(:status) { bridge.detailed_status(user) } it 'returns detailed status object' do - expect(status).to be_a Gitlab::Ci::Status::Success + expect(status).to be_a Gitlab::Ci::Status::Created end end diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index 1fb83fbb088..78be4a8131a 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -1929,6 +1929,13 @@ describe Ci::Pipeline, :mailer do it { is_expected.to be_an(Array) } end + describe '.bridgeable_statuses' do + subject { described_class.bridgeable_statuses } + + it { is_expected.to be_an(Array) } + it { is_expected.not_to include('created', 'preparing', 'pending') } + end + describe '#status' do let(:build) do create(:ci_build, :created, pipeline: pipeline, name: 'test') |