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
Boxiang Sun
gitlab-ce
Commits
9d27fb29
Commit
9d27fb29
authored
Mar 30, 2018
by
Balasankar "Balu" C
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more tests
parent
162062ce
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
3 deletions
+26
-3
spec/lib/backup/files_spec.rb
spec/lib/backup/files_spec.rb
+26
-3
No files found.
spec/lib/backup/files_spec.rb
View file @
9d27fb29
...
...
@@ -9,6 +9,9 @@ describe Backup::Files do
allow
(
progress
).
to
receive
(
:print
)
allow
(
FileUtils
).
to
receive
(
:mkdir_p
).
and_return
(
true
)
allow
(
FileUtils
).
to
receive
(
:mv
).
and_return
(
true
)
allow
(
File
).
to
receive
(
:exist?
).
and_return
(
true
)
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_any_instance_of
(
String
).
to
receive
(
:color
)
do
|
string
,
_color
|
string
...
...
@@ -25,11 +28,31 @@ describe Backup::Files do
Timecop
.
freeze
(
timestamp
)
{
example
.
run
}
end
describe
'folders with permission'
do
before
do
allow
(
subject
).
to
receive
(
:run_pipeline!
).
and_return
(
true
)
allow
(
subject
).
to
receive
(
:backup_existing_files
).
and_return
(
true
)
allow
(
Dir
).
to
receive
(
:glob
).
with
(
"/var/gitlab-registry/*"
,
File
::
FNM_DOTMATCH
).
and_return
([
"/var/gitlab-registry/."
,
"/var/gitlab-registry/.."
,
"/var/gitlab-registry/sample1"
])
end
it
'moves all necessary files'
do
allow
(
subject
).
to
receive
(
:backup_existing_files
).
and_call_original
expect
(
FileUtils
).
to
receive
(
:mv
).
with
([
"/var/gitlab-registry/sample1"
],
File
.
join
(
Gitlab
.
config
.
backup
.
path
,
"tmp"
,
"registry.
#{
Time
.
now
.
to_i
}
"
))
subject
.
restore
end
it
'raises no errors'
do
expect
{
subject
.
restore
}.
not_to
raise_error
end
it
'calls tar command with unlink'
do
expect
(
subject
).
to
receive
(
:run_pipeline!
).
with
([
%w(gzip -cd)
,
%w(tar --unlink-first --recursive-unlink -C /var/gitlab-registry -xf -)
],
any_args
)
subject
.
restore
end
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
...
...
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