diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-01-30 01:56:12 +0900 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2018-02-06 15:50:08 +0900 |
commit | c9ed3b2d4d208b7452fc2e057f11d28356c08887 (patch) | |
tree | 19c2ae6b63f4a901a98346f51a1bff85739672f0 /spec/uploaders | |
parent | edc936cde2730bb7c417343c582f2b8cf5b571c3 (diff) | |
download | gitlab-ce-c9ed3b2d4d208b7452fc2e057f11d28356c08887.tar.gz |
Add essential tests
Diffstat (limited to 'spec/uploaders')
-rw-r--r-- | spec/uploaders/job_artifact_uploader_spec.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/uploaders/job_artifact_uploader_spec.rb b/spec/uploaders/job_artifact_uploader_spec.rb index d606404e95d..ae631f23ae2 100644 --- a/spec/uploaders/job_artifact_uploader_spec.rb +++ b/spec/uploaders/job_artifact_uploader_spec.rb @@ -11,6 +11,49 @@ describe JobArtifactUploader do cache_dir: %r[artifacts/tmp/cache], work_dir: %r[artifacts/tmp/work] + describe '#open' do + subject { uploader.open } + + context 'when trace is stored in File storage' do + context 'when file exists' do + let(:file) do + fixture_file_upload( + Rails.root.join('spec/fixtures/trace/sample_trace'), 'text/plain') + end + + before do + uploader.store!(file) + end + + it 'returns io stream' do + is_expected.to be_a(IO) + end + end + + context 'when file does not exist' do + it 'returns nil' do + is_expected.to be_nil + end + end + end + end + + describe '#filename' do + subject { uploader.filename } + + context 'when artifact file_type is archive' do + let(:job_artifact) { create(:ci_job_artifact, :archive) } + + it { is_expected.to be_nil } + end + + context 'when artifact file_type is trace' do + let(:job_artifact) { create(:ci_job_artifact, :trace) } + + it { is_expected.to eq('trace.log') } + end + end + context 'file is stored in valid local_path' do let(:file) do fixture_file_upload( |