summaryrefslogtreecommitdiff
path: root/spec/tooling/quality/test_level_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/tooling/quality/test_level_spec.rb')
-rw-r--r--spec/tooling/quality/test_level_spec.rb36
1 files changed, 11 insertions, 25 deletions
diff --git a/spec/tooling/quality/test_level_spec.rb b/spec/tooling/quality/test_level_spec.rb
index 3f46b3e79f4..aac7d19c079 100644
--- a/spec/tooling/quality/test_level_spec.rb
+++ b/spec/tooling/quality/test_level_spec.rb
@@ -4,9 +4,9 @@ require 'fast_spec_helper'
require_relative '../../../tooling/quality/test_level'
-RSpec.describe Quality::TestLevel do
+RSpec.describe Quality::TestLevel, feature_category: :tooling do
describe 'TEST_LEVEL_FOLDERS constant' do
- it 'all directories it refers to exists', :aggregate_failures do
+ it 'ensures all directories it refers to exists', :aggregate_failures do
ee_only_directories = %w[
lib/ee/gitlab/background_migration
elastic
@@ -53,7 +53,7 @@ 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
@@ -128,7 +128,7 @@ 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
@@ -196,7 +196,7 @@ RSpec.describe Quality::TestLevel do
end
it 'returns the correct level for a background migration test' do
- expect(subject.level_for('spec/lib/gitlab/background_migration/archive_legacy_traces_spec.rb')).to eq(:migration)
+ expect(subject.level_for('spec/lib/gitlab/background_migration/archive_legacy_traces_spec.rb')).to eq(:background_migration)
end
it 'returns the correct level for an EE file without passing a prefix' do
@@ -208,7 +208,7 @@ RSpec.describe Quality::TestLevel do
end
it 'returns the correct level for a EE-namespaced background migration test' do
- expect(described_class.new('ee/').level_for('ee/spec/lib/ee/gitlab/background_migration/prune_orphaned_geo_events_spec.rb')).to eq(:migration)
+ expect(described_class.new('ee/').level_for('ee/spec/lib/ee/gitlab/background_migration/prune_orphaned_geo_events_spec.rb')).to eq(:background_migration)
end
it 'returns the correct level for an integration test' do
@@ -228,27 +228,13 @@ RSpec.describe Quality::TestLevel do
.to raise_error(described_class::UnknownTestLevelError,
%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 .+/tooling/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 'ensures all spec/ folders are covered by a test level' do
+ Dir['{,ee/}spec/**/*/'].each do |path|
+ next if path =~ %r{\A(ee/)?spec/(benchmarks|docs_screenshots|fixtures|frontend_integration|support)/}
- 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)
+ expect { subject.level_for(path) }.not_to raise_error
+ end
end
end
end