Commit f7f60ab5 authored by Shinya Maeda's avatar Shinya Maeda

Add spec for variables expressions with pipeline iid

parent 4beeb602
...@@ -156,22 +156,41 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do ...@@ -156,22 +156,41 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do
end end
end end
context 'when using only/except build policies' do context 'when variables policy is specified' do
let(:config) do context 'when using only/except build policies' do
{ rspec: { script: 'rspec', stage: 'test', only: ['master'] }, let(:config) do
prod: { script: 'cap prod', stage: 'deploy', only: ['tags'] } } { rspec: { script: 'rspec', stage: 'test', only: ['master'] },
end prod: { script: 'cap prod', stage: 'deploy', only: ['tags'] } }
end
let(:pipeline) do let(:pipeline) do
build(:ci_pipeline, ref: 'master', config: config) build(:ci_pipeline, ref: 'master', config: config)
end end
it 'populates pipeline according to used policies' do it 'populates pipeline according to used policies' do
step.perform! step.perform!
expect(pipeline.stages.size).to eq 1 expect(pipeline.stages.size).to eq 1
expect(pipeline.stages.first.builds.size).to eq 1 expect(pipeline.stages.first.builds.size).to eq 1
expect(pipeline.stages.first.builds.first.name).to eq 'rspec' expect(pipeline.stages.first.builds.first.name).to eq 'rspec'
end
context 'when variables expression is specified' do
let(:config) do
{ rspec: { script: 'rspec', only: { variables: ["$CI_PIPELINE_IID == '1'"] } },
prod: { script: 'cap prod', only: { variables: ["$CI_PIPELINE_IID == '1000'"] } } }
end
context 'when pipeline iid is the subject' do
it 'populates pipeline according to used policies' do
step.perform!
expect(pipeline.stages.size).to eq 1
expect(pipeline.stages.first.builds.size).to eq 1
expect(pipeline.stages.first.builds.first.name).to eq 'rspec'
end
end
end
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment