Commit ee8efb3d authored by Kamil Trzcinski's avatar Kamil Trzcinski

Sync ArtifactUploader specs with EE

parent 38c61ab6
require 'spec_helper' require 'spec_helper'
describe JobArtifactUploader do describe JobArtifactUploader do
set(:job_artifact) { create(:ci_job_artifact) } let(:job_artifact) { create(:ci_job_artifact) }
let(:uploader) { described_class.new(job_artifact, :file) } let(:uploader) { described_class.new(job_artifact, :file) }
let(:path) { Gitlab.config.artifacts.path } let(:local_path) { Gitlab.config.artifacts.path }
describe '#store_dir' do describe '#store_dir' do
subject { uploader.store_dir } subject { uploader.store_dir }
it { is_expected.to start_with(path) } let(:path) { "#{job_artifact.created_at.utc.strftime('%Y_%m_%d')}/#{job_artifact.project_id}/#{job_artifact.id}" }
it { is_expected.not_to end_with("#{job_artifact.project_id}/#{job_artifact.created_at.utc.strftime('%Y_%m')}/#{job_artifact.id}") }
it { is_expected.to match(/\h{2}\/\h{2}\/\h{64}\/\d{4}_\d{1,2}_\d{1,2}\/\d+\/\d+\z/) } 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
end end
describe '#cache_dir' do describe '#cache_dir' do
subject { uploader.cache_dir } subject { uploader.cache_dir }
it { is_expected.to start_with(path) } it { is_expected.to start_with(local_path) }
it { is_expected.to end_with('/tmp/cache') } it { is_expected.to end_with('/tmp/cache') }
end end
describe '#work_dir' do describe '#work_dir' do
subject { uploader.work_dir } subject { uploader.work_dir }
it { is_expected.to start_with(path) } it { is_expected.to start_with(local_path) }
it { is_expected.to end_with('/tmp/work') } it { is_expected.to end_with('/tmp/work') }
end end
context 'file is stored in valid path' do context 'file is stored in valid local_path' do
let(:file) do let(:file) do
fixture_file_upload(Rails.root.join( fixture_file_upload(Rails.root.join(
'spec/fixtures/ci_build_artifacts.zip'), 'application/zip') 'spec/fixtures/ci_build_artifacts.zip'), 'application/zip')
...@@ -39,7 +43,7 @@ describe JobArtifactUploader do ...@@ -39,7 +43,7 @@ describe JobArtifactUploader do
subject { uploader.file.path } subject { uploader.file.path }
it { is_expected.to start_with(path) } it { is_expected.to start_with(local_path) }
it { is_expected.to include("/#{job_artifact.created_at.utc.strftime('%Y_%m_%d')}/") } it { is_expected.to include("/#{job_artifact.created_at.utc.strftime('%Y_%m_%d')}/") }
it { is_expected.to include("/#{job_artifact.project_id.to_s}/") } it { is_expected.to include("/#{job_artifact.project_id.to_s}/") }
it { is_expected.to end_with("ci_build_artifacts.zip") } it { is_expected.to end_with("ci_build_artifacts.zip") }
......
require 'rails_helper' require 'rails_helper'
describe LegacyArtifactUploader do describe LegacyArtifactUploader do
set(:job) { create(:ci_build) } let(:job) { create(:ci_build) }
let(:uploader) { described_class.new(job, :artifacts_file) } let(:uploader) { described_class.new(job, :legacy_artifacts_file) }
let(:path) { Gitlab.config.artifacts.path } let(:local_path) { Gitlab.config.artifacts.path }
describe '.local_store_path' do describe '.local_store_path' do
subject { described_class.local_store_path } subject { described_class.local_store_path }
...@@ -18,28 +18,32 @@ describe LegacyArtifactUploader do ...@@ -18,28 +18,32 @@ describe LegacyArtifactUploader do
describe '.artifacts_upload_path' do describe '.artifacts_upload_path' do
subject { described_class.artifacts_upload_path } subject { described_class.artifacts_upload_path }
it { is_expected.to start_with(path) } it { is_expected.to start_with(local_path) }
it { is_expected.to end_with('tmp/uploads/') } it { is_expected.to end_with('tmp/uploads/') }
end end
describe '#store_dir' do describe '#store_dir' do
subject { uploader.store_dir } subject { uploader.store_dir }
it { is_expected.to start_with(path) } let(:path) { "#{job.created_at.utc.strftime('%Y_%m')}/#{job.project_id}/#{job.id}" }
it { is_expected.to end_with("#{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
end end
describe '#cache_dir' do describe '#cache_dir' do
subject { uploader.cache_dir } subject { uploader.cache_dir }
it { is_expected.to start_with(path) } it { is_expected.to start_with(local_path) }
it { is_expected.to end_with('/tmp/cache') } it { is_expected.to end_with('/tmp/cache') }
end end
describe '#work_dir' do describe '#work_dir' do
subject { uploader.work_dir } subject { uploader.work_dir }
it { is_expected.to start_with(path) } it { is_expected.to start_with(local_path) }
it { is_expected.to end_with('/tmp/work') } it { is_expected.to end_with('/tmp/work') }
end end
...@@ -51,12 +55,6 @@ describe LegacyArtifactUploader do ...@@ -51,12 +55,6 @@ describe LegacyArtifactUploader do
subject { uploader.filename } subject { uploader.filename }
it { is_expected.to be_nil } it { is_expected.to be_nil }
context 'with artifacts' do
let(:job) { create(:ci_build, :artifacts) }
it { is_expected.not_to be_nil }
end
end end
context 'file is stored in valid path' do context 'file is stored in valid path' do
...@@ -71,7 +69,7 @@ describe LegacyArtifactUploader do ...@@ -71,7 +69,7 @@ describe LegacyArtifactUploader do
subject { uploader.file.path } subject { uploader.file.path }
it { is_expected.to start_with(path) } it { is_expected.to start_with(local_path) }
it { is_expected.to include("/#{job.created_at.utc.strftime('%Y_%m')}/") } it { is_expected.to include("/#{job.created_at.utc.strftime('%Y_%m')}/") }
it { is_expected.to include("/#{job.project_id.to_s}/") } it { is_expected.to include("/#{job.project_id.to_s}/") }
it { is_expected.to end_with("ci_build_artifacts.zip") } it { is_expected.to end_with("ci_build_artifacts.zip") }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment