2017-09-21 04:34:12 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe JobArtifactUploader do
|
2017-11-23 13:41:49 -05:00
|
|
|
let(:job_artifact) { create(:ci_job_artifact) }
|
2017-09-21 04:34:12 -04:00
|
|
|
let(:uploader) { described_class.new(job_artifact, :file) }
|
2017-11-23 13:41:49 -05:00
|
|
|
let(:local_path) { Gitlab.config.artifacts.path }
|
2017-09-21 04:34:12 -04:00
|
|
|
|
|
|
|
describe '#store_dir' do
|
|
|
|
subject { uploader.store_dir }
|
|
|
|
|
2017-11-23 13:41:49 -05:00
|
|
|
let(:path) { "#{job_artifact.created_at.utc.strftime('%Y_%m_%d')}/#{job_artifact.project_id}/#{job_artifact.id}" }
|
|
|
|
|
|
|
|
context 'when using local storage' do
|
|
|
|
it { is_expected.to start_with(local_path) }
|
|
|
|
it { is_expected.to match(/\h{2}\/\h{2}\/\h{64}\/\d{4}_\d{1,2}_\d{1,2}\/\d+\/\d+\z/) }
|
|
|
|
it { is_expected.to end_with(path) }
|
|
|
|
end
|
2017-09-21 04:34:12 -04:00
|
|
|
end
|
2017-11-23 12:51:20 -05:00
|
|
|
|
|
|
|
describe '#cache_dir' do
|
|
|
|
subject { uploader.cache_dir }
|
|
|
|
|
2017-11-23 13:41:49 -05:00
|
|
|
it { is_expected.to start_with(local_path) }
|
2017-11-23 12:51:20 -05:00
|
|
|
it { is_expected.to end_with('/tmp/cache') }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#work_dir' do
|
|
|
|
subject { uploader.work_dir }
|
|
|
|
|
2017-11-23 13:41:49 -05:00
|
|
|
it { is_expected.to start_with(local_path) }
|
2017-11-23 12:51:20 -05:00
|
|
|
it { is_expected.to end_with('/tmp/work') }
|
|
|
|
end
|
|
|
|
|
2017-11-23 13:41:49 -05:00
|
|
|
context 'file is stored in valid local_path' do
|
2017-11-23 12:51:20 -05:00
|
|
|
let(:file) do
|
2017-11-23 13:53:31 -05:00
|
|
|
fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/ci_build_artifacts.zip'), 'application/zip')
|
2017-11-23 12:51:20 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
uploader.store!(file)
|
|
|
|
end
|
|
|
|
|
|
|
|
subject { uploader.file.path }
|
|
|
|
|
2017-11-23 13:41:49 -05:00
|
|
|
it { is_expected.to start_with(local_path) }
|
2017-11-23 12:51:20 -05:00
|
|
|
it { is_expected.to include("/#{job_artifact.created_at.utc.strftime('%Y_%m_%d')}/") }
|
2017-11-23 13:53:31 -05:00
|
|
|
it { is_expected.to include("/#{job_artifact.project_id}/") }
|
2017-11-23 12:51:20 -05:00
|
|
|
it { is_expected.to end_with("ci_build_artifacts.zip") }
|
|
|
|
end
|
2017-09-21 04:34:12 -04:00
|
|
|
end
|