Commit 6ed91266 authored by Shinya Maeda's avatar Shinya Maeda

Skip truncate when offset == size. Fix static analysys.

parent 65c11f32
......@@ -135,6 +135,7 @@ module Gitlab
def truncate(offset)
raise ArgumentError, 'Outside of file' if offset > size
return if offset == size # Skip the following process as it doesn't affect anything
@tell = offset
@size = offset
......
......@@ -345,7 +345,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
shared_examples_for 'deletes all build_trace_chunk and data in redis' do
it do
Gitlab::Redis::SharedState.with do |redis|
expect(redis.scan_each(match: "gitlab:ci:trace:?:chunks:?").to_a.count).to eq(3)
expect(redis.scan_each(match: "gitlab:ci:trace:?:chunks:?").to_a.size).to eq(3)
end
expect(described_class.count).to eq(3)
......@@ -355,14 +355,16 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
expect(described_class.count).to eq(0)
Gitlab::Redis::SharedState.with do |redis|
expect(redis.scan_each(match: "gitlab:ci:trace:?:chunks:?").to_a.count).to eq(0)
expect(redis.scan_each(match: "gitlab:ci:trace:?:chunks:?").to_a.size).to eq(0)
end
end
end
context 'when build is destroyed' do
context 'when traces are archived' do
let(:subject) do
project.builds.destroy_all
project.builds.each do |build|
build.success!
end
end
it_behaves_like 'deletes all build_trace_chunk and data in redis'
......
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