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
5e5df4b2
Commit
5e5df4b2
authored
Apr 06, 2020
by
pbair
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Alter task spec to better test behavior
parent
419d61da
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
8 deletions
+21
-8
spec/tasks/gitlab/db_rake_spec.rb
spec/tasks/gitlab/db_rake_spec.rb
+21
-8
No files found.
spec/tasks/gitlab/db_rake_spec.rb
View file @
5e5df4b2
...
...
@@ -100,26 +100,39 @@ describe 'gitlab:db namespace rake task' do
describe
'clean_structure_sql'
do
let_it_be
(
:clean_rake_task
)
{
'gitlab:db:clean_structure_sql'
}
let_it_be
(
:test_task_name
)
{
'gitlab:db:_test_multiple_structure_cleans'
}
let_it_be
(
:structure_file
)
{
'db/structure.sql'
}
let_it_be
(
:input
)
{
'this is structure data'
}
let
(
:output
)
{
StringIO
.
new
}
it
'reenables the task after running'
do
before
do
allow
(
File
).
to
receive
(
:read
).
with
(
structure_file
).
and_return
(
input
)
allow
(
File
).
to
receive
(
:open
).
with
(
structure_file
,
any_args
).
and_yield
(
output
)
expect_any_instance_of
(
Gitlab
::
Database
::
SchemaCleaner
).
to
receive
(
:clean
).
with
(
output
)
end
after
do
Rake
::
Task
[
test_task_name
].
clear
if
Rake
::
Task
.
task_defined?
(
test_task_name
)
end
run_rake_task
(
clean_rake_task
)
do
|
rake_task
|
expect
(
rake_task
).
to
receive
(
:reenable
)
it
'can be executed multiple times within another rake task'
do
Rake
::
Task
.
define_task
(
test_task_name
=>
:environment
)
do
expect_next_instance_of
(
Gitlab
::
Database
::
SchemaCleaner
)
do
|
cleaner
|
expect
(
cleaner
).
to
receive
(
:clean
).
with
(
output
)
end
Rake
::
Task
[
clean_rake_task
].
invoke
expect_next_instance_of
(
Gitlab
::
Database
::
SchemaCleaner
)
do
|
cleaner
|
expect
(
cleaner
).
to
receive
(
:clean
).
with
(
output
)
end
Rake
::
Task
[
clean_rake_task
].
invoke
end
run_rake_task
(
test_task_name
)
end
end
def
run_rake_task
(
task_name
)
rake_task
=
Rake
::
Task
[
task_name
]
rake_task
.
reenable
yield
rake_task
if
block_given?
Rake
::
Task
[
task_name
].
reenable
Rake
.
application
.
invoke_task
task_name
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