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
0fe8ce94
Commit
0fe8ce94
authored
Aug 10, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring spec for Geo::RepositoriesCleanUpWorker
parent
3d953e3a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
24 deletions
+20
-24
spec/workers/geo/repositories_clean_up_worker_spec.rb
spec/workers/geo/repositories_clean_up_worker_spec.rb
+20
-24
No files found.
spec/workers/geo/repositories_clean_up_worker_spec.rb
View file @
0fe8ce94
require
'spec_helper'
describe
Geo
::
RepositoriesCleanUpWorker
do
let!
(
:geo_node
)
{
create
(
:geo_node
)
}
let
(
:synced_group
)
{
create
(
:group
)
}
let!
(
:project_in_synced_group
)
{
create
(
:project
,
group:
synced_group
)
}
let!
(
:unsynced_project
)
{
create
(
:project
,
:repository
)
}
describe
'#perform'
do
let
(
:geo_node
)
{
create
(
:geo_node
)
}
before
do
allow_any_instance_of
(
Gitlab
::
ExclusiveLease
).
to
receive
(
:try_obtain
)
{
true
}
end
context
'when node has namespace restrictions'
do
let
(
:synced_group
)
{
create
(
:group
)
}
let
(
:geo_node
)
{
create
(
:geo_node
,
namespaces:
[
synced_group
])
}
it
'performs GeoRepositoryDestroyWorker for each project that does not belong to selected namespaces to replicate'
do
geo_node
.
update_attribute
(
:namespaces
,
[
synced_group
])
project_in_synced_group
=
create
(
:project
,
group:
synced_group
)
unsynced_project
=
create
(
:project
,
:repository
)
expect
(
GeoRepositoryDestroyWorker
).
to
receive
(
:perform_async
)
.
with
(
unsynced_project
.
id
,
unsynced_project
.
name
,
unsynced_project
.
full_path
)
.
once
.
and_return
(
1
)
expect
(
GeoRepositoryDestroyWorker
).
not_to
receive
(
:perform_async
)
.
with
(
project_in_synced_group
.
id
,
project_in_synced_group
.
name
,
project_in_synced_group
.
full_path
)
subject
.
perform
(
geo_node
.
id
)
end
it
'does not perform GeoRepositoryDestroyWorker when repository does not exist'
do
allow_any_instance_of
(
Gitlab
::
Shell
).
to
receive
(
:exists?
)
.
with
(
unsynced_project
.
repository_storage_path
,
"
#{
unsynced_project
.
disk_path
}
.git"
)
.
and_return
(
false
)
create
(
:project
)
expect
(
GeoRepositoryDestroyWorker
).
not_to
receive
(
:perform_async
)
...
...
@@ -33,28 +35,22 @@ describe Geo::RepositoriesCleanUpWorker do
end
end
context
'when does not node have namespace restrictions'
do
it
'does not perform GeoRepositoryDestroyWorker'
do
it
'does not perform GeoRepositoryDestroyWorker when does not node have namespace restrictions'
do
expect
(
GeoRepositoryDestroyWorker
).
not_to
receive
(
:perform_async
)
subject
.
perform
(
geo_node
.
id
)
end
end
context
'when cannnot obtain a lease'
do
it
'does not perform GeoRepositoryDestroyWorker'
do
it
'does not perform GeoRepositoryDestroyWorker when cannnot obtain a lease'
do
allow_any_instance_of
(
Gitlab
::
ExclusiveLease
).
to
receive
(
:try_obtain
)
{
false
}
expect
(
GeoRepositoryDestroyWorker
).
not_to
receive
(
:perform_async
)
subject
.
perform
(
geo_node
.
id
)
end
end
context
'when Geo node could not be found'
do
it
'does not raise an error'
do
it
'does not raise an error when node could not be found'
do
expect
{
subject
.
perform
(
-
1
)
}.
not_to
raise_error
end
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