From 154b9bae142ba15fec753f44327654595094b879 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 17 Mar 2020 21:09:16 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- spec/lib/quality/test_level_spec.rb | 40 +++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'spec/lib/quality') diff --git a/spec/lib/quality/test_level_spec.rb b/spec/lib/quality/test_level_spec.rb index 34163c6cfbc..6042ab24787 100644 --- a/spec/lib/quality/test_level_spec.rb +++ b/spec/lib/quality/test_level_spec.rb @@ -28,7 +28,14 @@ RSpec.describe Quality::TestLevel do context 'when level is migration' do it 'returns a pattern' do expect(subject.pattern(:migration)) - .to eq("spec/{migrations,lib/gitlab/background_migration,lib/ee/gitlab/background_migration}{,/**/}*_spec.rb") + .to eq("spec/{migrations}{,/**/}*_spec.rb") + end + end + + context 'when level is background_migration' do + it 'returns a pattern' do + expect(subject.pattern(:background_migration)) + .to eq("spec/{lib/gitlab/background_migration,lib/ee/gitlab/background_migration}{,/**/}*_spec.rb") end end @@ -89,7 +96,14 @@ RSpec.describe Quality::TestLevel do context 'when level is migration' do it 'returns a regexp' do expect(subject.regexp(:migration)) - .to eq(%r{spec/(migrations|lib/gitlab/background_migration|lib/ee/gitlab/background_migration)}) + .to eq(%r{spec/(migrations)}) + end + end + + context 'when level is background_migration' do + it 'returns a regexp' do + expect(subject.regexp(:background_migration)) + .to eq(%r{spec/(lib/gitlab/background_migration|lib/ee/gitlab/background_migration)}) end end @@ -160,4 +174,26 @@ RSpec.describe Quality::TestLevel do %r{Test level for spec/unknown/foo_spec.rb couldn't be set. Please rename the file properly or change the test level detection regexes in .+/lib/quality/test_level.rb.}) end end + + describe '#background_migration?' do + it 'returns false for a unit test' do + expect(subject.background_migration?('spec/models/abuse_report_spec.rb')).to be(false) + end + + it 'returns true for a migration test' do + expect(subject.background_migration?('spec/migrations/add_default_and_free_plans_spec.rb')).to be(false) + end + + it 'returns true for a background migration test' do + expect(subject.background_migration?('spec/lib/gitlab/background_migration/archive_legacy_traces_spec.rb')).to be(true) + end + + it 'returns true for a geo migration test' do + expect(described_class.new('ee/').background_migration?('ee/spec/migrations/geo/migrate_ci_job_artifacts_to_separate_registry_spec.rb')).to be(false) + end + + it 'returns true for a EE-namespaced background migration test' do + expect(described_class.new('ee/').background_migration?('ee/spec/lib/ee/gitlab/background_migration/prune_orphaned_geo_events_spec.rb')).to be(true) + end + end end -- cgit v1.2.1