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/services | |
parent | edc936cde2730bb7c417343c582f2b8cf5b571c3 (diff) | |
download | gitlab-ce-c9ed3b2d4d208b7452fc2e057f11d28356c08887.tar.gz |
Add essential tests
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/ci/create_trace_artifact_service_spec.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/services/ci/create_trace_artifact_service_spec.rb b/spec/services/ci/create_trace_artifact_service_spec.rb new file mode 100644 index 00000000000..e70b1a2bce2 --- /dev/null +++ b/spec/services/ci/create_trace_artifact_service_spec.rb @@ -0,0 +1,43 @@ +require 'spec_helper' + +describe Ci::CreateTraceArtifactService do + describe '#execute' do + subject { described_class.new(nil, nil).execute(job) } + + let(:job) { create(:ci_build) } + + context 'when the job does not have trace artifact' do + context 'when the job has a trace file' do + before do + allow_any_instance_of(Gitlab::Ci::Trace) + .to receive(:default_path) { expand_fixture_path('trace/sample_trace') } + + allow_any_instance_of(JobArtifactUploader).to receive(:move_to_cache) { false } + allow_any_instance_of(JobArtifactUploader).to receive(:move_to_store) { false } + end + + it 'creates trace artifact' do + expect { subject }.to change { Ci::JobArtifact.count }.by(1) + + expect(job.job_artifacts_trace.read_attribute(:file)).to eq('trace.log') + end + + context 'when the job has already had trace artifact' do + before do + create(:ci_job_artifact, :trace, job: job) + end + + it 'does not create trace artifact' do + expect { subject }.not_to change { Ci::JobArtifact.count } + end + end + end + + context 'when the job does not have a trace file' do + it 'does not create trace artifact' do + expect { subject }.not_to change { Ci::JobArtifact.count } + end + end + end + end +end |