Commit 3a5cb44f authored by Shinya Maeda's avatar Shinya Maeda

Fix static analysys

parent 583b49f0
...@@ -125,6 +125,7 @@ module Gitlab ...@@ -125,6 +125,7 @@ module Gitlab
FileUtils.touch(temp_path) FileUtils.touch(temp_path)
size = IO.copy_stream(src_stream, temp_path) size = IO.copy_stream(src_stream, temp_path)
raise 'Not all saved' unless size == src_stream.size raise 'Not all saved' unless size == src_stream.size
yield(temp_path) yield(temp_path)
end end
end end
......
...@@ -439,7 +439,7 @@ describe Gitlab::Ci::Trace do ...@@ -439,7 +439,7 @@ describe Gitlab::Ci::Trace do
expect(build.old_trace).to be_nil expect(build.old_trace).to be_nil
expect(src_checksum) expect(src_checksum)
.to eq(Digest::SHA256.file(build.job_artifacts_trace.file.path).digest) .to eq(Digest::SHA256.file(build.job_artifacts_trace.file.path).digest)
end end
end end
shared_examples 'source trace in database stays intact' do |error:| shared_examples 'source trace in database stays intact' do |error:|
...@@ -463,7 +463,7 @@ describe Gitlab::Ci::Trace do ...@@ -463,7 +463,7 @@ describe Gitlab::Ci::Trace do
context 'when failed to create clone file' do context 'when failed to create clone file' do
before do before do
allow_any_instance_of(Gitlab::Ci::Trace) allow_any_instance_of(described_class)
.to receive(:clone_file!).and_raise('Not all saved') .to receive(:clone_file!).and_raise('Not all saved')
end end
...@@ -474,7 +474,7 @@ describe Gitlab::Ci::Trace do ...@@ -474,7 +474,7 @@ describe Gitlab::Ci::Trace do
before do before do
allow_any_instance_of(Ci::JobArtifact).to receive(:save).and_return(false) allow_any_instance_of(Ci::JobArtifact).to receive(:save).and_return(false)
allow_any_instance_of(Ci::JobArtifact).to receive_message_chain(:errors, :full_messages) allow_any_instance_of(Ci::JobArtifact).to receive_message_chain(:errors, :full_messages)
.and_return(["Error", 'Error']) .and_return(%w[Error Error])
end end
it_behaves_like 'source trace file stays intact', error: ActiveRecord::RecordInvalid it_behaves_like 'source trace file stays intact', error: ActiveRecord::RecordInvalid
...@@ -494,7 +494,7 @@ describe Gitlab::Ci::Trace do ...@@ -494,7 +494,7 @@ describe Gitlab::Ci::Trace do
context 'when failed to create clone file' do context 'when failed to create clone file' do
before do before do
allow_any_instance_of(Gitlab::Ci::Trace) allow_any_instance_of(described_class)
.to receive(:clone_file!).and_raise('Not all saved') .to receive(:clone_file!).and_raise('Not all saved')
end end
...@@ -505,7 +505,7 @@ describe Gitlab::Ci::Trace do ...@@ -505,7 +505,7 @@ describe Gitlab::Ci::Trace do
before do before do
allow_any_instance_of(Ci::JobArtifact).to receive(:save).and_return(false) allow_any_instance_of(Ci::JobArtifact).to receive(:save).and_return(false)
allow_any_instance_of(Ci::JobArtifact).to receive_message_chain(:errors, :full_messages) allow_any_instance_of(Ci::JobArtifact).to receive_message_chain(:errors, :full_messages)
.and_return(["Error", 'Error']) .and_return(%w[Error Error])
end end
it_behaves_like 'source trace in database stays intact', error: ActiveRecord::RecordInvalid it_behaves_like 'source trace in database stays intact', error: ActiveRecord::RecordInvalid
...@@ -519,7 +519,7 @@ describe Gitlab::Ci::Trace do ...@@ -519,7 +519,7 @@ describe Gitlab::Ci::Trace do
end end
it 'does not archive' do it 'does not archive' do
expect_any_instance_of(Gitlab::Ci::Trace).not_to receive(:archive_stream!) expect_any_instance_of(described_class).not_to receive(:archive_stream!)
expect { subject }.to raise_error('Already archived') expect { subject }.to raise_error('Already archived')
expect(build.job_artifacts_trace.file.exists?).to be_truthy expect(build.job_artifacts_trace.file.exists?).to be_truthy
end end
...@@ -529,7 +529,7 @@ describe Gitlab::Ci::Trace do ...@@ -529,7 +529,7 @@ describe Gitlab::Ci::Trace do
let!(:build) { create(:ci_build, :running, :trace_live) } let!(:build) { create(:ci_build, :running, :trace_live) }
it 'does not archive' do it 'does not archive' do
expect_any_instance_of(Gitlab::Ci::Trace).not_to receive(:archive_stream!) expect_any_instance_of(described_class).not_to receive(:archive_stream!)
expect { subject }.to raise_error('Job is not finished yet') expect { subject }.to raise_error('Job is not finished yet')
expect(build.trace.exist?).to be_truthy expect(build.trace.exist?).to be_truthy
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment