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
5a2581d1
Commit
5a2581d1
authored
Jun 29, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spec for Geo::RepositoryDeletedEventStore
parent
e94e8216
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
19 deletions
+53
-19
spec/services/ee/projects/destroy_service_spec.rb
spec/services/ee/projects/destroy_service_spec.rb
+9
-19
spec/services/geo/repository_deleted_event_store_spec.rb
spec/services/geo/repository_deleted_event_store_spec.rb
+44
-0
No files found.
spec/services/ee/projects/destroy_service_spec.rb
View file @
5a2581d1
...
...
@@ -10,32 +10,22 @@ describe Projects::DestroyService, services: true do
let!
(
:wiki_path
)
{
project
.
path_with_namespace
+
'.wiki'
}
let!
(
:storage_name
)
{
project
.
repository_storage
}
let!
(
:storage_path
)
{
project
.
repository_storage_path
}
let!
(
:geo_node
)
{
create
(
:geo_node
,
:primary
,
:current
)
}
subject
{
described_class
.
new
(
project
,
user
,
{})
}
before
do
stub_container_registry_config
(
enabled:
true
)
stub_container_registry_tags
(
repository: :any
,
tags:
[])
end
context
'Geo primary'
do
it
'logs the event'
do
# Run sidekiq immediatly to check that renamed repository will be removed
Sidekiq
::
Testing
.
inline!
{
destroy_project
(
project
,
user
,
{})
}
event
=
Geo
::
RepositoryDeletedEvent
.
first
context
'when running on a primary node'
do
let!
(
:geo_node
)
{
create
(
:geo_node
,
:primary
,
:current
)
}
expect
(
Geo
::
EventLog
.
count
).
to
eq
(
1
)
expect
(
Geo
::
RepositoryDeletedEvent
.
count
).
to
eq
(
1
)
expect
(
event
.
project_id
).
to
eq
(
project_id
)
expect
(
event
.
deleted_path
).
to
eq
(
project_path
)
expect
(
event
.
deleted_wiki_path
).
to
eq
(
wiki_path
)
expect
(
event
.
deleted_project_name
).
to
eq
(
project_name
)
expect
(
event
.
repository_storage_name
).
to
eq
(
storage_name
)
expect
(
event
.
repository_storage_path
).
to
eq
(
storage_path
)
it
'logs an event to the Geo event log'
do
# Run sidekiq immediatly to check that renamed repository will be removed
Sidekiq
::
Testing
.
inline!
do
expect
{
subject
.
execute
}.
to
change
(
Geo
::
RepositoryDeletedEvent
,
:count
).
by
(
1
)
end
end
def
destroy_project
(
project
,
user
,
params
=
{})
described_class
.
new
(
project
,
user
,
params
).
execute
end
end
spec/services/geo/repository_deleted_event_store_spec.rb
0 → 100644
View file @
5a2581d1
require
'spec_helper'
describe
Geo
::
RepositoryDeletedEventStore
,
services:
true
do
let
(
:project
)
{
create
(
:empty_project
,
path:
'bar'
)
}
let!
(
:project_id
)
{
project
.
id
}
let!
(
:project_name
)
{
project
.
name
}
let!
(
:repo_path
)
{
project
.
full_path
}
let!
(
:wiki_path
)
{
"
#{
project
.
full_path
}
.wiki"
}
let!
(
:storage_name
)
{
project
.
repository_storage
}
let!
(
:storage_path
)
{
project
.
repository_storage_path
}
subject
{
described_class
.
new
(
project
,
repo_path:
repo_path
,
wiki_path:
wiki_path
)
}
describe
'#create'
do
it
'does not create an event when not running on a primary node'
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:primary?
)
{
false
}
expect
{
subject
.
create
}.
not_to
change
(
Geo
::
RepositoryDeletedEvent
,
:count
)
end
context
'when running on a primary node'
do
before
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:primary?
)
{
true
}
end
it
'creates a deleted event'
do
expect
{
subject
.
create
}.
to
change
(
Geo
::
RepositoryDeletedEvent
,
:count
).
by
(
1
)
end
it
'tracks information for the deleted project'
do
subject
.
create
event
=
Geo
::
RepositoryDeletedEvent
.
last
expect
(
event
.
project_id
).
to
eq
(
project_id
)
expect
(
event
.
deleted_path
).
to
eq
(
repo_path
)
expect
(
event
.
deleted_wiki_path
).
to
eq
(
wiki_path
)
expect
(
event
.
deleted_project_name
).
to
eq
(
project_name
)
expect
(
event
.
repository_storage_name
).
to
eq
(
storage_name
)
expect
(
event
.
repository_storage_path
).
to
eq
(
storage_path
)
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