Commit 9e12baea authored by Grzegorz Bizon's avatar Grzegorz Bizon

Add test for evaluating bridge variables policy

parent d14b1a71
......@@ -15,6 +15,7 @@ describe Gitlab::Ci::Build::Policy::Variables do
before do
pipeline.variables.build(key: 'CI_PROJECT_NAME', value: '')
pipeline.variables.build(key: 'MY_VARIABLE', value: 'my-var')
end
describe '#satisfied_by?' do
......@@ -24,6 +25,12 @@ describe Gitlab::Ci::Build::Policy::Variables do
expect(policy).to be_satisfied_by(pipeline, seed)
end
it 'is satisfied by a matching pipeline variable' do
policy = described_class.new(['$MY_VARIABLE'])
expect(policy).to be_satisfied_by(pipeline, seed)
end
it 'is not satisfied by an overridden empty variable' do
policy = described_class.new(['$CI_PROJECT_NAME'])
......@@ -68,5 +75,19 @@ describe Gitlab::Ci::Build::Policy::Variables do
expect(pipeline).not_to be_persisted
expect(seed.to_resource).not_to be_persisted
end
context 'when a bridge job is used' do
let(:bridge) do
build(:ci_bridge, pipeline: pipeline, project: project, ref: 'master')
end
let(:seed) { double('bridge seed', to_resource: bridge) }
it 'is satisfied by a matching expression for a bridge job' do
policy = described_class.new(['$MY_VARIABLE'])
expect(policy).to be_satisfied_by(pipeline, seed)
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