2017-06-01 07:52:19 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2017-11-23 15:57:27 +00:00
|
|
|
describe LegacyArtifactUploader do
|
2017-11-23 18:41:49 +00:00
|
|
|
let(:job) { create(:ci_build) }
|
|
|
|
let(:uploader) { described_class.new(job, :legacy_artifacts_file) }
|
|
|
|
let(:local_path) { Gitlab.config.artifacts.path }
|
2017-06-01 07:52:19 +00:00
|
|
|
|
2017-11-23 17:51:20 +00:00
|
|
|
describe '.local_store_path' do
|
|
|
|
subject { described_class.local_store_path }
|
2017-06-01 07:52:19 +00:00
|
|
|
|
|
|
|
it "delegate to artifacts path" do
|
|
|
|
expect(Gitlab.config.artifacts).to receive(:path)
|
|
|
|
|
|
|
|
subject
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.artifacts_upload_path' do
|
|
|
|
subject { described_class.artifacts_upload_path }
|
2017-06-05 05:12:18 +00:00
|
|
|
|
2017-11-23 18:41:49 +00:00
|
|
|
it { is_expected.to start_with(local_path) }
|
2017-06-01 07:52:19 +00:00
|
|
|
it { is_expected.to end_with('tmp/uploads/') }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#store_dir' do
|
|
|
|
subject { uploader.store_dir }
|
2017-06-05 05:12:18 +00:00
|
|
|
|
2017-11-23 18:41:49 +00:00
|
|
|
let(:path) { "#{job.created_at.utc.strftime('%Y_%m')}/#{job.project_id}/#{job.id}" }
|
|
|
|
|
|
|
|
context 'when using local storage' do
|
|
|
|
it { is_expected.to start_with(local_path) }
|
|
|
|
it { is_expected.to end_with(path) }
|
|
|
|
end
|
2017-06-01 07:52:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe '#cache_dir' do
|
|
|
|
subject { uploader.cache_dir }
|
2017-06-05 05:12:18 +00:00
|
|
|
|
2017-11-23 18:41:49 +00:00
|
|
|
it { is_expected.to start_with(local_path) }
|
2017-06-05 05:12:18 +00:00
|
|
|
it { is_expected.to end_with('/tmp/cache') }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#work_dir' do
|
|
|
|
subject { uploader.work_dir }
|
|
|
|
|
2017-11-23 18:41:49 +00:00
|
|
|
it { is_expected.to start_with(local_path) }
|
2017-06-05 05:12:18 +00:00
|
|
|
it { is_expected.to end_with('/tmp/work') }
|
2017-06-01 07:52:19 +00:00
|
|
|
end
|
2017-06-12 21:42:11 +00:00
|
|
|
|
|
|
|
describe '#filename' do
|
|
|
|
# we need to use uploader, as this makes to use mounter
|
|
|
|
# which initialises uploader.file object
|
|
|
|
let(:uploader) { job.artifacts_file }
|
|
|
|
|
|
|
|
subject { uploader.filename }
|
|
|
|
|
|
|
|
it { is_expected.to be_nil }
|
|
|
|
end
|
2017-11-23 17:51:20 +00:00
|
|
|
|
|
|
|
context 'file is stored in valid path' do
|
|
|
|
let(:file) do
|
2017-11-23 18:53:31 +00:00
|
|
|
fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/ci_build_artifacts.zip'), 'application/zip')
|
2017-11-23 17:51:20 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
uploader.store!(file)
|
|
|
|
end
|
|
|
|
|
|
|
|
subject { uploader.file.path }
|
|
|
|
|
2017-11-23 18:41:49 +00:00
|
|
|
it { is_expected.to start_with(local_path) }
|
2017-11-23 17:51:20 +00:00
|
|
|
it { is_expected.to include("/#{job.created_at.utc.strftime('%Y_%m')}/") }
|
2017-11-23 18:53:31 +00:00
|
|
|
it { is_expected.to include("/#{job.project_id}/") }
|
2017-11-23 17:51:20 +00:00
|
|
|
it { is_expected.to end_with("ci_build_artifacts.zip") }
|
|
|
|
end
|
2017-06-01 07:52:19 +00:00
|
|
|
end
|