2017-06-01 16:15:46 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe LfsObjectUploader do
|
2017-06-05 01:12:18 -04:00
|
|
|
let(:lfs_object) { create(:lfs_object, :with_file) }
|
2017-09-07 17:27:04 -04:00
|
|
|
let(:uploader) { described_class.new(lfs_object, :file) }
|
2017-06-05 01:12:18 -04:00
|
|
|
let(:path) { Gitlab.config.lfs.storage_path }
|
2017-06-01 16:15:46 -04:00
|
|
|
|
2018-02-02 08:59:43 -05:00
|
|
|
subject { uploader }
|
2017-06-05 01:12:18 -04:00
|
|
|
|
2018-02-02 08:59:43 -05:00
|
|
|
it_behaves_like "builds correct paths",
|
|
|
|
store_dir: %r[\h{2}/\h{2}],
|
|
|
|
cache_dir: %r[/lfs-objects/tmp/cache],
|
|
|
|
work_dir: %r[/lfs-objects/tmp/work]
|
2017-06-05 01:12:18 -04:00
|
|
|
|
2018-02-02 08:59:43 -05:00
|
|
|
context "object store is REMOTE" do
|
|
|
|
before do
|
|
|
|
stub_lfs_object_storage
|
|
|
|
end
|
2017-06-05 01:12:18 -04:00
|
|
|
|
2018-02-02 08:59:43 -05:00
|
|
|
include_context 'with storage', described_class::Store::REMOTE
|
2017-06-05 01:12:18 -04:00
|
|
|
|
2018-02-02 08:59:43 -05:00
|
|
|
it_behaves_like "builds correct paths",
|
|
|
|
store_dir: %r[\h{2}/\h{2}]
|
2017-06-05 01:12:18 -04:00
|
|
|
end
|
2017-09-07 17:27:04 -04:00
|
|
|
|
|
|
|
describe 'migration to object storage' do
|
|
|
|
context 'with object storage disabled' do
|
|
|
|
it "is skipped" do
|
2018-02-21 11:43:21 -05:00
|
|
|
expect(ObjectStorage::BackgroundMoveWorker).not_to receive(:perform_async)
|
2017-09-07 17:27:04 -04:00
|
|
|
|
|
|
|
lfs_object
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with object storage enabled' do
|
|
|
|
before do
|
2017-12-08 04:09:06 -05:00
|
|
|
stub_lfs_object_storage(background_upload: true)
|
2017-09-07 17:27:04 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'is scheduled to run after creation' do
|
2018-02-21 11:43:21 -05:00
|
|
|
expect(ObjectStorage::BackgroundMoveWorker).to receive(:perform_async).with(described_class.name, 'LfsObject', :file, kind_of(Numeric))
|
2017-09-07 17:27:04 -04:00
|
|
|
|
|
|
|
lfs_object
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'remote file' do
|
2018-05-01 16:27:54 -04:00
|
|
|
let(:lfs_object) { create(:lfs_object, :object_storage, :with_file) }
|
2017-09-07 17:27:04 -04:00
|
|
|
|
|
|
|
context 'with object storage enabled' do
|
|
|
|
before do
|
|
|
|
stub_lfs_object_storage
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'can store file remotely' do
|
2018-02-21 11:43:21 -05:00
|
|
|
allow(ObjectStorage::BackgroundMoveWorker).to receive(:perform_async)
|
2017-09-07 17:27:04 -04:00
|
|
|
|
2018-05-01 16:27:54 -04:00
|
|
|
lfs_object
|
2017-09-07 17:27:04 -04:00
|
|
|
|
2018-05-01 16:27:54 -04:00
|
|
|
expect(lfs_object.file_store).to eq(described_class::Store::REMOTE)
|
2017-09-07 17:27:04 -04:00
|
|
|
expect(lfs_object.file.path).not_to be_blank
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-06-01 16:15:46 -04:00
|
|
|
end
|