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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
c0ef9958
Commit
c0ef9958
authored
Mar 30, 2018
by
Balasankar "Balu" C
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add basic tests
parent
8785f237
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
0 deletions
+55
-0
spec/lib/backup/files_spec.rb
spec/lib/backup/files_spec.rb
+44
-0
spec/lib/backup/repository_spec.rb
spec/lib/backup/repository_spec.rb
+11
-0
No files found.
spec/lib/backup/files_spec.rb
0 → 100644
View file @
c0ef9958
require
'spec_helper'
describe
Backup
::
Files
do
let
(
:progress
)
{
StringIO
.
new
}
let!
(
:project
)
{
create
(
:project
)
}
before
do
allow
(
progress
).
to
receive
(
:puts
)
allow
(
progress
).
to
receive
(
:print
)
allow
(
FileUtils
).
to
receive
(
:mkdir_p
).
and_return
(
true
)
allow
(
FileUtils
).
to
receive
(
:mv
).
and_return
(
true
)
allow_any_instance_of
(
String
).
to
receive
(
:color
)
do
|
string
,
_color
|
string
end
allow_any_instance_of
(
described_class
).
to
receive
(
:progress
).
and_return
(
progress
)
end
describe
'#restore'
do
subject
{
described_class
.
new
(
'registry'
,
'/var/gitlab-registry'
)
}
let
(
:timestamp
)
{
Time
.
utc
(
2017
,
3
,
22
)
}
around
do
|
example
|
Timecop
.
freeze
(
timestamp
)
{
example
.
run
}
end
describe
'folders without permissions'
do
before
do
allow
(
File
).
to
receive
(
:realpath
).
with
(
"/var/gitlab-registry"
).
and_return
(
"/var/gitlab-registry"
)
allow
(
File
).
to
receive
(
:realpath
).
with
(
"/var/gitlab-registry/.."
).
and_return
(
"/var"
)
allow
(
File
).
to
receive
(
:exist?
).
and_return
(
true
)
allow
(
FileUtils
).
to
receive
(
:mv
).
and_raise
(
Errno
::
EACCES
)
allow
(
subject
).
to
receive
(
:run_pipeline!
).
and_return
(
true
)
end
it
'shows error message'
do
expect
(
subject
).
to
receive
(
:access_denied_error
).
with
(
"/var/gitlab-registry"
)
subject
.
restore
end
end
end
end
spec/lib/backup/repository_spec.rb
View file @
c0ef9958
...
...
@@ -70,6 +70,17 @@ describe Backup::Repository do
end
end
end
describe
'folders without permissions'
do
before
do
allow
(
FileUtils
).
to
receive
(
:mv
).
and_raise
(
Errno
::
EACCES
)
end
it
'shows error message'
do
expect
(
subject
).
to
receive
(
:access_denied_error
)
subject
.
restore
end
end
end
describe
'#empty_repo?'
do
...
...
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