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
3bc1b6c7
Commit
3bc1b6c7
authored
Jun 24, 2020
by
Albert Salim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Match multiple migration conventions
parent
8dba90d8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
5 deletions
+18
-5
spec/tooling/lib/tooling/test_file_finder_spec.rb
spec/tooling/lib/tooling/test_file_finder_spec.rb
+10
-2
tooling/lib/tooling/test_file_finder.rb
tooling/lib/tooling/test_file_finder.rb
+8
-3
No files found.
spec/tooling/lib/tooling/test_file_finder_spec.rb
View file @
3bc1b6c7
...
...
@@ -124,7 +124,11 @@ RSpec.describe Tooling::TestFileFinder do
let
(
:file
)
{
'db/migrate/20191023152913_add_default_and_free_plans.rb'
}
it
'returns the matching migration spec'
do
expect
(
subject
.
test_files
).
to
contain_exactly
(
'spec/migrations/add_default_and_free_plans_spec.rb'
)
test_files
=
%w[
spec/migrations/add_default_and_free_plans_spec.rb
spec/migrations/20191023152913_add_default_and_free_plans_spec.rb
]
expect
(
subject
.
test_files
).
to
contain_exactly
(
*
test_files
)
end
end
...
...
@@ -132,7 +136,11 @@ RSpec.describe Tooling::TestFileFinder do
let
(
:file
)
{
'db/post_migrate/20200608072931_backfill_imported_snippet_repositories.rb'
}
it
'returns the matching migration spec'
do
expect
(
subject
.
test_files
).
to
contain_exactly
(
'spec/migrations/backfill_imported_snippet_repositories_spec.rb'
)
test_files
=
%w[
spec/migrations/backfill_imported_snippet_repositories_spec.rb
spec/migrations/20200608072931_backfill_imported_snippet_repositories_spec.rb
]
expect
(
subject
.
test_files
).
to
contain_exactly
(
*
test_files
)
end
end
...
...
tooling/lib/tooling/test_file_finder.rb
View file @
3bc1b6c7
...
...
@@ -37,7 +37,8 @@ module Tooling
def
impact
(
file
)
@pattern_matchers
.
each_with_object
(
Set
.
new
)
do
|
(
pattern
,
block
),
result
|
if
(
match
=
pattern
.
match
(
file
))
result
<<
block
.
call
(
match
)
test_files
=
block
.
call
(
match
)
result
.
merge
(
Array
(
test_files
))
end
end
.
to_a
end
...
...
@@ -72,9 +73,13 @@ module Tooling
impact
.
associate
(
%r{app/(.+)
\.
rb$}
)
{
|
match
|
"spec/
#{
match
[
1
]
}
_spec.rb"
}
impact
.
associate
(
%r{(tooling/)?lib/(.+)
\.
rb$}
)
{
|
match
|
"spec/
#{
match
[
1
]
}
lib/
#{
match
[
2
]
}
_spec.rb"
}
impact
.
associate
(
%r{config/initializers/(.+).rb$}
)
{
|
match
|
"spec/initializers/
#{
match
[
1
]
}
_spec.rb"
}
impact
.
associate
(
%r{db/post_migrate/([0-9]+)_(.+).rb$}
)
{
|
match
|
"spec/migrations/
#{
match
[
2
]
}
_spec.rb"
}
impact
.
associate
(
%r{db/migrate/([0-9]+)_(.+).rb$}
)
{
|
match
|
"spec/migrations/
#{
match
[
2
]
}
_spec.rb"
}
impact
.
associate
(
'db/structure.sql'
)
{
'spec/db/schema_spec.rb'
}
impact
.
associate
(
%r{db/(?:post_)?migrate/([0-9]+)_(.+).rb$}
)
do
|
match
|
[
"spec/migrations/
#{
match
[
2
]
}
_spec.rb"
,
"spec/migrations/
#{
match
[
1
]
}
_
#{
match
[
2
]
}
_spec.rb"
]
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