summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2018-02-28 18:14:41 +0900
committerShinya Maeda <shinya@gitlab.com>2018-03-06 21:43:19 +0900
commit91117452e1c106352171aea56ef336dbafd322a6 (patch)
treea8458561cbd4869365e423eafaf3f77b6cdf6aac /spec
parent9ca8a5d43f103fcbcb278e08d6afa15b33ad2e29 (diff)
downloadgitlab-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.rb17
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