2019-07-25 01:21:37 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-03-18 13:26:18 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 05:08:32 -04:00
|
|
|
RSpec.describe Backup::Uploads do
|
2019-03-18 13:26:18 -04:00
|
|
|
let(:progress) { StringIO.new }
|
2019-12-12 07:07:33 -05:00
|
|
|
|
2019-03-18 13:26:18 -04:00
|
|
|
subject(:backup) { described_class.new(progress) }
|
|
|
|
|
|
|
|
describe '#initialize' do
|
|
|
|
it 'uses the correct upload dir' do
|
|
|
|
Dir.mktmpdir do |tmpdir|
|
|
|
|
FileUtils.mkdir_p("#{tmpdir}/uploads")
|
|
|
|
|
|
|
|
allow(Gitlab.config.uploads).to receive(:storage_path) { tmpdir }
|
|
|
|
|
|
|
|
expect(backup.app_files_dir).to eq("#{tmpdir}/uploads")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-09-14 08:09:34 -04:00
|
|
|
|
|
|
|
describe '#dump' do
|
|
|
|
before do
|
|
|
|
allow(File).to receive(:realpath).with('/var/uploads').and_return('/var/uploads')
|
|
|
|
allow(File).to receive(:realpath).with('/var/uploads/..').and_return('/var')
|
|
|
|
allow(Gitlab.config.uploads).to receive(:storage_path) { '/var' }
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'uses the correct upload dir' do
|
|
|
|
expect(backup.app_files_dir).to eq('/var/uploads')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'excludes tmp from backup tar' do
|
|
|
|
expect(backup).to receive(:tar).and_return('blabla-tar')
|
2020-10-29 05:08:38 -04:00
|
|
|
expect(backup).to receive(:run_pipeline!).with([%w(blabla-tar --exclude=lost+found --exclude=./tmp -C /var/uploads -cf - .), 'gzip -c -1'], any_args).and_return([[true, true], ''])
|
|
|
|
expect(backup).to receive(:pipeline_succeeded?).and_return(true)
|
2020-09-14 08:09:34 -04:00
|
|
|
backup.dump
|
|
|
|
end
|
|
|
|
end
|
2019-03-18 13:26:18 -04:00
|
|
|
end
|