diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-11 18:15:55 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-11 18:15:55 +0300 |
commit | a8281ac43424e4b820286823bdb48f068b21d7d3 (patch) | |
tree | f8064c724e33f22402ecc4bd0a8c23ea01e6eac1 /spec/lib/backup/object_backup_spec.rb | |
parent | 22391da1261240ecc15aa15cbb19b089339902b5 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/backup/object_backup_spec.rb')
-rw-r--r-- | spec/lib/backup/object_backup_spec.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/lib/backup/object_backup_spec.rb b/spec/lib/backup/object_backup_spec.rb new file mode 100644 index 00000000000..6192b5c3482 --- /dev/null +++ b/spec/lib/backup/object_backup_spec.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.shared_examples 'backup object' do |setting| + let(:progress) { StringIO.new } + let(:backup_path) { "/var/#{setting}" } + + subject(:backup) { described_class.new(progress) } + + describe '#dump' do + before do + allow(File).to receive(:realpath).and_call_original + allow(File).to receive(:realpath).with(backup_path).and_return(backup_path) + allow(File).to receive(:realpath).with("#{backup_path}/..").and_return('/var') + allow(Settings.send(setting)).to receive(:storage_path).and_return(backup_path) + end + + it 'uses the correct storage dir in tar command and excludes tmp', :aggregate_failures do + expect(backup.app_files_dir).to eq(backup_path) + expect(backup).to receive(:tar).and_return('blabla-tar') + expect(backup).to receive(:run_pipeline!).with([%W(blabla-tar --exclude=lost+found --exclude=./tmp -C #{backup_path} -cf - .), 'gzip -c -1'], any_args).and_return([[true, true], '']) + expect(backup).to receive(:pipeline_succeeded?).and_return(true) + + backup.dump + end + end +end + +RSpec.describe Backup::Packages do + it_behaves_like 'backup object', 'packages' +end + +RSpec.describe Backup::TerraformState do + it_behaves_like 'backup object', 'terraform_state' +end |