diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-02-28 18:14:41 +0900 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2018-03-06 21:43:19 +0900 |
commit | 91117452e1c106352171aea56ef336dbafd322a6 (patch) | |
tree | a8458561cbd4869365e423eafaf3f77b6cdf6aac /spec | |
parent | 9ca8a5d43f103fcbcb278e08d6afa15b33ad2e29 (diff) | |
download | gitlab-ce-91117452e1c106352171aea56ef336dbafd322a6.tar.gz |
Raise an error if conditions are not fulfilled in archive method
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/ci/trace_spec.rb | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/spec/lib/gitlab/ci/trace_spec.rb b/spec/lib/gitlab/ci/trace_spec.rb index e52f5fc39d4..ba7153ed04d 100644 --- a/spec/lib/gitlab/ci/trace_spec.rb +++ b/spec/lib/gitlab/ci/trace_spec.rb @@ -455,7 +455,7 @@ describe Gitlab::Ci::Trace do context 'when job does not have trace artifact' do context 'when trace file stored in default path' do - let!(:build) { create(:ci_build, :trace_live) } + let!(:build) { create(:ci_build, :success, :trace_live) } let!(:src_path) { trace.read { |s| return s.path } } let!(:src_checksum) { Digest::SHA256.file(src_path).digest } @@ -481,7 +481,8 @@ describe Gitlab::Ci::Trace do end end - context 'when trace stored in database' do + context 'when trace is stored in database' do + let(:build) { create(:ci_build, :success) } let(:trace_content) { IO.read(expand_fixture_path('trace/sample_trace')) } let!(:src_checksum) { Digest::SHA256.digest(trace_content) } @@ -519,9 +520,19 @@ describe Gitlab::Ci::Trace do it 'does not archive' do expect_any_instance_of(Gitlab::Ci::Trace).not_to receive(:archive_stream!) - expect { subject }.not_to change { Ci::JobArtifact.count } + expect { subject }.to raise_error('Already archived') expect(build.job_artifacts_trace.file.exists?).to be_truthy end end + + context 'when job is not finished yet' do + let!(:build) { create(:ci_build, :running, :trace_live) } + + it 'does not archive' do + expect_any_instance_of(Gitlab::Ci::Trace).not_to receive(:archive_stream!) + expect { subject }.to raise_error('Job is not finished yet') + expect(build.trace.exist?).to be_truthy + end + end end end |