Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2018-01-29 19:56:12 +0300
committerShinya Maeda <shinya@gitlab.com>2018-02-06 09:50:08 +0300
commitc9ed3b2d4d208b7452fc2e057f11d28356c08887 (patch)
tree19c2ae6b63f4a901a98346f51a1bff85739672f0 /spec/uploaders
parentedc936cde2730bb7c417343c582f2b8cf5b571c3 (diff)
Add essential tests
Diffstat (limited to 'spec/uploaders')
-rw-r--r--spec/uploaders/job_artifact_uploader_spec.rb43
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(