gitlab-org--gitlab-foss/spec/uploaders/job_artifact_uploader_spec.rb

44 lines
1.3 KiB
Ruby
Raw Normal View History

require 'spec_helper'
describe JobArtifactUploader do
let(:store) { described_class::Store::LOCAL }
let(:job_artifact) { create(:ci_job_artifact, file_store: store) }
let(:uploader) { described_class.new(job_artifact, :file) }
subject { uploader }
it_behaves_like "builds correct paths",
store_dir: %r[\h{2}/\h{2}/\h{64}/\d{4}_\d{1,2}_\d{1,2}/\d+/\d+\z],
cache_dir: %r[artifacts/tmp/cache],
work_dir: %r[artifacts/tmp/work]
2017-11-23 18:41:49 +00:00
context "object store is REMOTE" do
before do
stub_artifacts_object_storage
2017-11-23 18:41:49 +00:00
end
include_context 'with storage', described_class::Store::REMOTE
it_behaves_like "builds correct paths",
store_dir: %r[\h{2}/\h{2}/\h{64}/\d{4}_\d{1,2}_\d{1,2}/\d+/\d+\z]
end
2017-11-23 18:41:49 +00:00
context 'file is stored in valid local_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')
end
before do
uploader.store!(file)
end
subject { uploader.file.path }
it { is_expected.to start_with("#{uploader.root}/#{uploader.class.base_dir}") }
it { is_expected.to include("/#{job_artifact.created_at.utc.strftime('%Y_%m_%d')}/") }
2017-11-23 18:53:31 +00:00
it { is_expected.to include("/#{job_artifact.project_id}/") }
it { is_expected.to end_with("ci_build_artifacts.zip") }
end
end