summaryrefslogtreecommitdiff
path: root/spec/lib/backup/manager_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-05 00:07:49 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-05 00:07:49 +0000
commit77237c5a6b9044f58beabc54d3589e5fa09cbfba (patch)
treef43188047fe8955f6cf78e05ae9c2e8f6a019e0b /spec/lib/backup/manager_spec.rb
parent2fd92f2dc784ade9cb4e1c33dd60cbfad7b86818 (diff)
downloadgitlab-ce-77237c5a6b9044f58beabc54d3589e5fa09cbfba.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/backup/manager_spec.rb')
-rw-r--r--spec/lib/backup/manager_spec.rb53
1 files changed, 44 insertions, 9 deletions
diff --git a/spec/lib/backup/manager_spec.rb b/spec/lib/backup/manager_spec.rb
index 06ad0557e37..cee299522ce 100644
--- a/spec/lib/backup/manager_spec.rb
+++ b/spec/lib/backup/manager_spec.rb
@@ -214,6 +214,30 @@ describe Backup::Manager do
end
end
+ describe 'verify_backup_version' do
+ context 'on version mismatch' do
+ let(:gitlab_version) { Gitlab::VERSION }
+
+ it 'stops the process' do
+ allow(YAML).to receive(:load_file)
+ .and_return({ gitlab_version: "not #{gitlab_version}" })
+
+ expect { subject.verify_backup_version }.to raise_error SystemExit
+ end
+ end
+
+ context 'on version match' do
+ let(:gitlab_version) { Gitlab::VERSION }
+
+ it 'does nothing' do
+ allow(YAML).to receive(:load_file)
+ .and_return({ gitlab_version: "#{gitlab_version}" })
+
+ expect { subject.verify_backup_version }.not_to raise_error
+ end
+ end
+ end
+
describe '#unpack' do
context 'when there are no backup files in the directory' do
before do
@@ -292,6 +316,23 @@ describe Backup::Manager do
expect(progress).to have_received(:puts).with(a_string_matching('done'))
end
end
+
+ context 'when there is a non-tarred backup in the directory' do
+ before do
+ allow(Dir).to receieve(:glob).and_return(
+ [
+ 'backup_information.yml'
+ ]
+ )
+
+ it 'selects the non-tarred backup to restore from' do
+ expect { subject.unpack }.to output.to_stdout
+ expect(progress).to have_received(:puts)
+ .with(a_string_matching('Non tarred backup found '))
+ expect(Kernel).not_to receive(:system)
+ end
+ end
+ end
end
describe '#upload' do
@@ -329,9 +370,7 @@ describe Backup::Manager do
.with(hash_including(key: backup_filename, public: false))
.and_return(true)
- Dir.chdir(Gitlab.config.backup.path) do
- subject.upload
- end
+ subject.upload
end
it 'adds the DIRECTORY environment variable if present' do
@@ -341,9 +380,7 @@ describe Backup::Manager do
.with(hash_including(key: "daily/#{backup_filename}", public: false))
.and_return(true)
- Dir.chdir(Gitlab.config.backup.path) do
- subject.upload
- end
+ subject.upload
end
end
@@ -373,9 +410,7 @@ describe Backup::Manager do
.with(hash_excluding(public: false))
.and_return(true)
- Dir.chdir(Gitlab.config.backup.path) do
- subject.upload
- end
+ subject.upload
end
end
end