Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
525e5135
Commit
525e5135
authored
Mar 12, 2020
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow to detect background migration in Quality::TestLevel
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
36a5f50e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
3 deletions
+45
-3
lib/quality/test_level.rb
lib/quality/test_level.rb
+7
-1
spec/lib/quality/test_level_spec.rb
spec/lib/quality/test_level_spec.rb
+38
-2
No files found.
lib/quality/test_level.rb
View file @
525e5135
...
...
@@ -7,6 +7,8 @@ module Quality
TEST_LEVEL_FOLDERS
=
{
migration:
%w[
migrations
]
,
background_migration:
%w[
lib/gitlab/background_migration
lib/ee/gitlab/background_migration
]
,
...
...
@@ -70,7 +72,7 @@ module Quality
case
file_path
# Detect migration first since some background migration tests are under
# spec/lib/gitlab/background_migration and tests under spec/lib are unit by default
when
regexp
(
:migration
)
when
regexp
(
:migration
)
,
regexp
(
:background_migration
)
:migration
when
regexp
(
:unit
)
:unit
...
...
@@ -83,6 +85,10 @@ module Quality
end
end
def
background_migration?
(
file_path
)
!!
(
file_path
=~
regexp
(
:background_migration
))
end
private
def
folders_pattern
(
level
)
...
...
spec/lib/quality/test_level_spec.rb
View file @
525e5135
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment