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
6fe2744d
Commit
6fe2744d
authored
May 23, 2017
by
Achilleas Pipinellis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for removing old backups with the new timestamp
parent
450e2cd8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
6 deletions
+13
-6
spec/lib/gitlab/backup/manager_spec.rb
spec/lib/gitlab/backup/manager_spec.rb
+13
-6
No files found.
spec/lib/gitlab/backup/manager_spec.rb
View file @
6fe2744d
...
...
@@ -24,6 +24,8 @@ describe Backup::Manager, lib: true do
describe
'#remove_old'
do
let
(
:files
)
do
[
'1495528448_2017_05_23_9.3.0-pre_gitlab_backup.tar'
,
'1495528448_2017_05_23_9.3.0_gitlab_backup.tar'
,
'1451606400_2016_01_01_gitlab_backup.tar'
,
'1451520000_2015_12_31_gitlab_backup.tar'
,
'1450742400_2015_12_22_gitlab_backup.tar'
,
...
...
@@ -37,7 +39,7 @@ describe Backup::Manager, lib: true do
allow
(
Dir
).
to
receive
(
:chdir
).
and_yield
allow
(
Dir
).
to
receive
(
:glob
).
and_return
(
files
)
allow
(
FileUtils
).
to
receive
(
:rm
)
allow
(
Time
).
to
receive
(
:now
).
and_return
(
Time
.
utc
(
201
6
))
allow
(
Time
).
to
receive
(
:now
).
and_return
(
Time
.
utc
(
201
7
))
end
context
'when keep_time is zero'
do
...
...
@@ -79,26 +81,31 @@ describe Backup::Manager, lib: true do
subject
.
remove_old
end
it
'removes matching files with a human-readable timestamp'
do
it
'removes matching files with a human-readable versioned timestamp'
do
expect
(
FileUtils
).
to
have_received
(
:rm
).
with
(
files
[
0
])
expect
(
FileUtils
).
to
have_received
(
:rm
).
with
(
files
[
1
])
expect
(
FileUtils
).
to
have_received
(
:rm
).
with
(
files
[
2
])
end
it
'removes matching files with
out a human-readable
timestamp'
do
it
'removes matching files with
a human-readable non-versioned
timestamp'
do
expect
(
FileUtils
).
to
have_received
(
:rm
).
with
(
files
[
3
])
expect
(
FileUtils
).
to
have_received
(
:rm
).
with
(
files
[
4
])
end
it
'removes matching files without a human-readable timestamp'
do
expect
(
FileUtils
).
to
have_received
(
:rm
).
with
(
files
[
5
])
expect
(
FileUtils
).
to
have_received
(
:rm
).
with
(
files
[
6
])
end
it
'does not remove files that are not old enough'
do
expect
(
FileUtils
).
not_to
have_received
(
:rm
).
with
(
files
[
0
])
end
it
'does not remove non-matching files'
do
expect
(
FileUtils
).
not_to
have_received
(
:rm
).
with
(
files
[
5
])
expect
(
FileUtils
).
not_to
have_received
(
:rm
).
with
(
files
[
7
])
end
it
'prints a done message'
do
expect
(
progress
).
to
have_received
(
:puts
).
with
(
'done. (
4
removed)'
)
expect
(
progress
).
to
have_received
(
:puts
).
with
(
'done. (
5
removed)'
)
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