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
a531a2d9
Commit
a531a2d9
authored
Jul 14, 2017
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved BaseSyncService specs
parent
8311839f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
1 deletion
+40
-1
app/services/geo/base_sync_service.rb
app/services/geo/base_sync_service.rb
+4
-0
spec/services/geo/base_sync_service_spec.rb
spec/services/geo/base_sync_service_spec.rb
+36
-1
No files found.
app/services/geo/base_sync_service.rb
View file @
a531a2d9
...
...
@@ -31,6 +31,10 @@ module Geo
private
def
sync_repository
raise
NotImplementedError
,
'This class should implement sync_repository method'
end
def
registry
@registry
||=
Geo
::
ProjectRegistry
.
find_or_initialize_by
(
project_id:
project
.
id
)
end
...
...
spec/services/geo/base_sync_service_spec.rb
View file @
a531a2d9
require
'spec_helper'
describe
Geo
::
BaseSyncService
,
services:
true
do
let
(
:project
)
{
double
(
'project'
)}
let
(
:project
)
{
build
(
'project'
)}
subject
{
described_class
.
new
(
project
)
}
describe
'#execute'
do
context
'when can acquire exclusive lease'
do
before
do
allow_any_instance_of
(
Gitlab
::
ExclusiveLease
).
to
receive
(
:try_obtain
)
{
12345
}
end
it
'executes the synchronization'
do
expect
(
subject
).
to
receive
(
:sync_repository
)
subject
.
execute
end
end
context
'when exclusive lease is not acquired'
do
before
do
allow_any_instance_of
(
Gitlab
::
ExclusiveLease
).
to
receive
(
:try_obtain
)
{
nil
}
end
it
'is does not execute synchronization'
do
expect
(
subject
).
not_to
receive
(
:sync_repository
)
subject
.
execute
end
end
end
describe
'#lease_key'
do
it
'returns a key in the correct pattern'
do
described_class
.
type
=
:test
allow
(
project
).
to
receive
(
:id
)
{
999
}
expect
(
subject
.
lease_key
).
to
eq
(
'geo_sync_service:test:999'
)
end
end
describe
'#primary_ssh_path_prefix'
do
let!
(
:primary_node
)
{
create
(
:geo_node
,
:primary
,
host:
'primary-geo-node'
)
}
...
...
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