diff options
author | Rémy Coutable <remy@rymai.me> | 2018-03-05 11:55:52 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-03-05 11:55:52 +0000 |
commit | 6fc571414031767dd9fdab87da66137f9ebe95d3 (patch) | |
tree | e02f8a1c1e5cced369ad4211686ca7233c23b696 | |
parent | e53324988b4a599fe3cbdc549d6dad7b15138a0d (diff) | |
parent | 94dc43f37ce20347b5ad67aee0cf90f5c86a814f (diff) | |
download | gitlab-ce-6fc571414031767dd9fdab87da66137f9ebe95d3.tar.gz |
Merge branch 'sh-fix-backup-restore-cleanup' into 'master'
Clean up backup/restore temporary directory
See merge request gitlab-org/gitlab-ce!17499
-rw-r--r-- | spec/lib/backup/repository_spec.rb | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/spec/lib/backup/repository_spec.rb b/spec/lib/backup/repository_spec.rb index f7b1a61f4f8..a9b5ed1112a 100644 --- a/spec/lib/backup/repository_spec.rb +++ b/spec/lib/backup/repository_spec.rb @@ -28,6 +28,23 @@ describe Backup::Repository do end describe '#restore' do + subject { described_class.new } + + let(:timestamp) { Time.utc(2017, 3, 22) } + let(:temp_dirs) do + Gitlab.config.repositories.storages.map do |name, storage| + File.join(storage['path'], '..', 'repositories.old.' + timestamp.to_i.to_s) + end + end + + around do |example| + Timecop.freeze(timestamp) { example.run } + end + + after do + temp_dirs.each { |path| FileUtils.rm_rf(path) } + end + describe 'command failure' do before do allow(Gitlab::Popen).to receive(:popen).and_return(['error', 1]) @@ -35,7 +52,7 @@ describe Backup::Repository do context 'hashed storage' do it 'shows the appropriate error' do - described_class.new.restore + subject.restore expect(progress).to have_received(:puts).with("Ignoring error on #{project.full_path} (#{project.disk_path}) - error") end @@ -45,7 +62,7 @@ describe Backup::Repository do let!(:project) { create(:project, :legacy_storage) } it 'shows the appropriate error' do - described_class.new.restore + subject.restore expect(progress).to have_received(:puts).with("Ignoring error on #{project.full_path} - error") end |