diff options
Diffstat (limited to 'spec/lib/gitlab/ci/pipeline')
5 files changed, 35 insertions, 111 deletions
diff --git a/spec/lib/gitlab/ci/pipeline/chain/remove_unwanted_chat_jobs_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/remove_unwanted_chat_jobs_spec.rb index 8b9de16ce5f..11e3f32c7ce 100644 --- a/spec/lib/gitlab/ci/pipeline/chain/remove_unwanted_chat_jobs_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/chain/remove_unwanted_chat_jobs_spec.rb @@ -11,7 +11,7 @@ RSpec.describe ::Gitlab::Ci::Pipeline::Chain::RemoveUnwantedChatJobs do let(:command) do double(:command, - config_processor: double(:processor, + yaml_processor_result: double(:processor, jobs: { echo: double(:job_echo), rspec: double(:job_rspec) }), project: project, chat_data: { command: 'echo' }) @@ -25,7 +25,7 @@ RSpec.describe ::Gitlab::Ci::Pipeline::Chain::RemoveUnwantedChatJobs do subject - expect(command.config_processor.jobs.keys).to eq([:echo]) + expect(command.yaml_processor_result.jobs.keys).to eq([:echo]) end it 'does not remove any jobs for non chat-pipelines' do @@ -33,7 +33,7 @@ RSpec.describe ::Gitlab::Ci::Pipeline::Chain::RemoveUnwantedChatJobs do subject - expect(command.config_processor.jobs.keys).to eq([:echo, :rspec]) + expect(command.yaml_processor_result.jobs.keys).to eq([:echo, :rspec]) end end end diff --git a/spec/lib/gitlab/ci/pipeline/chain/validate/external_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/validate/external_spec.rb index de580d2e148..e55281f9705 100644 --- a/spec/lib/gitlab/ci/pipeline/chain/validate/external_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/chain/validate/external_spec.rb @@ -31,20 +31,20 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Validate::External do CI_YAML end - let(:yaml_processor) do + let(:yaml_processor_result) do ::Gitlab::Ci::YamlProcessor.new( ci_yaml, { project: project, sha: pipeline.sha, user: user } - ) + ).execute end let(:save_incompleted) { true } let(:command) do Gitlab::Ci::Pipeline::Chain::Command.new( - project: project, current_user: user, config_processor: yaml_processor, save_incompleted: save_incompleted + project: project, current_user: user, yaml_processor_result: yaml_processor_result, save_incompleted: save_incompleted ) end @@ -128,7 +128,7 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Validate::External do end describe '#validation_service_payload' do - subject(:validation_service_payload) { step.send(:validation_service_payload, pipeline, command.config_processor.stages_attributes) } + subject(:validation_service_payload) { step.send(:validation_service_payload, pipeline, command.yaml_processor_result.stages_attributes) } it 'respects the defined schema' do expect(validation_service_payload).to match_schema('/external_validation') diff --git a/spec/lib/gitlab/ci/pipeline/expression/lexer_spec.rb b/spec/lib/gitlab/ci/pipeline/expression/lexer_spec.rb index 6e242faa885..fc5725a4d17 100644 --- a/spec/lib/gitlab/ci/pipeline/expression/lexer_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/expression/lexer_spec.rb @@ -90,24 +90,7 @@ RSpec.describe Gitlab::Ci::Pipeline::Expression::Lexer do end with_them do - context 'when ci_if_parenthesis_enabled is enabled' do - before do - stub_feature_flags(ci_if_parenthesis_enabled: true) - end - - it { is_expected.to eq(tokens) } - end - - context 'when ci_if_parenthesis_enabled is disabled' do - before do - stub_feature_flags(ci_if_parenthesis_enabled: false) - end - - it do - expect { subject } - .to raise_error described_class::SyntaxError - end - end + it { is_expected.to eq(tokens) } end end end diff --git a/spec/lib/gitlab/ci/pipeline/expression/parser_spec.rb b/spec/lib/gitlab/ci/pipeline/expression/parser_spec.rb index 3394a75ac0a..a02c247925e 100644 --- a/spec/lib/gitlab/ci/pipeline/expression/parser_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/expression/parser_spec.rb @@ -3,10 +3,6 @@ require 'spec_helper' RSpec.describe Gitlab::Ci::Pipeline::Expression::Parser do - before do - stub_feature_flags(ci_if_parenthesis_enabled: true) - end - describe '#tree' do context 'validates simple operators' do using RSpec::Parameterized::TableSyntax @@ -31,36 +27,15 @@ RSpec.describe Gitlab::Ci::Pipeline::Expression::Parser do context 'when combining && and OR operators' do subject { described_class.seed('$VAR1 == "a" || $VAR2 == "b" && $VAR3 == "c" || $VAR4 == "d" && $VAR5 == "e"').tree } - context 'when parenthesis engine is enabled' do - before do - stub_feature_flags(ci_if_parenthesis_enabled: true) - end - - it 'returns operations in a correct order' do - expect(subject.inspect) - .to eq('or(or(equals($VAR1, "a"), and(equals($VAR2, "b"), equals($VAR3, "c"))), and(equals($VAR4, "d"), equals($VAR5, "e")))') - end - end - - context 'when parenthesis engine is disabled (legacy)' do - before do - stub_feature_flags(ci_if_parenthesis_enabled: false) - end - - it 'returns operations in a invalid order' do - expect(subject.inspect) - .to eq('or(equals($VAR1, "a"), and(equals($VAR2, "b"), or(equals($VAR3, "c"), and(equals($VAR4, "d"), equals($VAR5, "e")))))') - end + it 'returns operations in a correct order' do + expect(subject.inspect) + .to eq('or(or(equals($VAR1, "a"), and(equals($VAR2, "b"), equals($VAR3, "c"))), and(equals($VAR4, "d"), equals($VAR5, "e")))') end end context 'when using parenthesis' do subject { described_class.seed('(($VAR1 == "a" || $VAR2 == "b") && $VAR3 == "c" || $VAR4 == "d") && $VAR5 == "e"').tree } - before do - stub_feature_flags(ci_if_parenthesis_enabled: true) - end - it 'returns operations in a correct order' do expect(subject.inspect) .to eq('and(or(and(or(equals($VAR1, "a"), equals($VAR2, "b")), equals($VAR3, "c")), equals($VAR4, "d")), equals($VAR5, "e"))') @@ -96,38 +71,21 @@ RSpec.describe Gitlab::Ci::Pipeline::Expression::Parser do end context 'when parenthesis are unmatched' do - context 'when parenthesis engine is enabled' do - before do - stub_feature_flags(ci_if_parenthesis_enabled: true) - end - - where(:expression) do - [ - '$VAR == (', - '$VAR2 == ("aa"', - '$VAR2 == ("aa"))', - '$VAR2 == "aa")', - '(($VAR2 == "aa")', - '($VAR2 == "aa"))' - ] - end - - with_them do - it 'raises a ParseError' do - expect { described_class.seed(expression).tree } - .to raise_error Gitlab::Ci::Pipeline::Expression::Parser::ParseError - end - end + where(:expression) do + [ + '$VAR == (', + '$VAR2 == ("aa"', + '$VAR2 == ("aa"))', + '$VAR2 == "aa")', + '(($VAR2 == "aa")', + '($VAR2 == "aa"))' + ] end - context 'when parenthesis engine is disabled' do - before do - stub_feature_flags(ci_if_parenthesis_enabled: false) - end - - it 'raises an SyntaxError' do - expect { described_class.seed('$VAR == (').tree } - .to raise_error Gitlab::Ci::Pipeline::Expression::Lexer::SyntaxError + with_them do + it 'raises a ParseError' do + expect { described_class.seed(expression).tree } + .to raise_error Gitlab::Ci::Pipeline::Expression::Parser::ParseError 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 733ab30132d..34df0e86a18 100644 --- a/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb @@ -931,47 +931,30 @@ RSpec.describe Gitlab::Ci::Pipeline::Seed::Build do context 'when using 101 needs' do let(:needs_count) { 101 } - context 'when ci_plan_needs_size_limit is disabled' do + it "returns an error" do + expect(subject.errors).to contain_exactly( + "rspec: one job can only need 50 others, but you have listed 101. See needs keyword documentation for more details") + end + + context 'when ci_needs_size_limit is set to 100' do before do - stub_feature_flags(ci_plan_needs_size_limit: false) + project.actual_limits.update!(ci_needs_size_limit: 100) end it "returns an error" do expect(subject.errors).to contain_exactly( - "rspec: one job can only need 10 others, but you have listed 101. See needs keyword documentation for more details") + "rspec: one job can only need 100 others, but you have listed 101. See needs keyword documentation for more details") end end - context 'when ci_plan_needs_size_limit is enabled' do + context 'when ci_needs_size_limit is set to 0' do before do - stub_feature_flags(ci_plan_needs_size_limit: true) + project.actual_limits.update!(ci_needs_size_limit: 0) end it "returns an error" do expect(subject.errors).to contain_exactly( - "rspec: one job can only need 50 others, but you have listed 101. See needs keyword documentation for more details") - end - - context 'when ci_needs_size_limit is set to 100' do - before do - project.actual_limits.update!(ci_needs_size_limit: 100) - end - - it "returns an error" do - expect(subject.errors).to contain_exactly( - "rspec: one job can only need 100 others, but you have listed 101. See needs keyword documentation for more details") - end - end - - context 'when ci_needs_size_limit is set to 0' do - before do - project.actual_limits.update!(ci_needs_size_limit: 0) - end - - it "returns an error" do - expect(subject.errors).to contain_exactly( - "rspec: one job can only need 0 others, but you have listed 101. See needs keyword documentation for more details") - end + "rspec: one job can only need 0 others, but you have listed 101. See needs keyword documentation for more details") end end end |