debian-mirror-gitlab/spec/lib/gitlab/git/diff_collection_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

784 lines
18 KiB
Ruby
Raw Normal View History

2020-01-01 13:55:28 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe Gitlab::Git::DiffCollection, :seed_helper do
2020-06-23 00:09:42 +05:30
before do
stub_const('MutatingConstantIterator', Class.new)
MutatingConstantIterator.class_eval do
include Enumerable
2021-01-03 14:25:43 +05:30
attr_reader :size
2020-06-23 00:09:42 +05:30
def initialize(count, value)
@count = count
2021-01-03 14:25:43 +05:30
@size = count
2020-06-23 00:09:42 +05:30
@value = value
end
def each
return enum_for(:each) unless block_given?
loop do
2020-10-24 23:57:45 +05:30
break if @count == 0
2020-06-23 00:09:42 +05:30
# It is critical to decrement before yielding. We may never reach the lines after 'yield'.
@count -= 1
yield @value
end
end
end
end
2021-04-29 21:17:54 +05:30
let(:overflow_max_bytes) { false }
let(:overflow_max_files) { false }
let(:overflow_max_lines) { false }
shared_examples 'overflow stuff' do
it 'returns the expected overflow values' do
subject.overflow?
expect(subject.overflow_max_bytes?).to eq(overflow_max_bytes)
expect(subject.overflow_max_files?).to eq(overflow_max_files)
expect(subject.overflow_max_lines?).to eq(overflow_max_lines)
end
end
2017-08-17 22:00:37 +05:30
subject do
Gitlab::Git::DiffCollection.new(
iterator,
max_files: max_files,
max_lines: max_lines,
2017-09-10 17:25:29 +05:30
limits: limits,
expanded: expanded
2017-08-17 22:00:37 +05:30
)
end
2019-12-21 20:55:43 +05:30
2017-09-10 17:25:29 +05:30
let(:iterator) { MutatingConstantIterator.new(file_count, fake_diff(line_length, line_count)) }
2017-08-17 22:00:37 +05:30
let(:file_count) { 0 }
let(:line_length) { 1 }
let(:line_count) { 1 }
let(:max_files) { 10 }
let(:max_lines) { 100 }
2017-09-10 17:25:29 +05:30
let(:limits) { true }
let(:expanded) { true }
2017-08-17 22:00:37 +05:30
describe '#to_a' do
subject { super().to_a }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to be_kind_of ::Array }
end
describe '#decorate!' do
let(:file_count) { 3 }
it 'modifies the array in place' do
count = 0
subject.decorate! { |d| !d.nil? && count += 1 }
expect(subject.to_a).to eq([1, 2, 3])
expect(count).to eq(3)
end
it 'avoids future iterator iterations' do
subject.decorate! { |d| d unless d.nil? }
expect(iterator).not_to receive(:each)
subject.overflow?
end
end
context 'overflow handling' do
2021-04-29 21:17:54 +05:30
subject { super() }
let(:collapsed_safe_files) { false }
let(:collapsed_safe_lines) { false }
2017-08-17 22:00:37 +05:30
context 'adding few enough files' do
let(:file_count) { 3 }
context 'and few enough lines' do
let(:line_count) { 10 }
2021-04-29 21:17:54 +05:30
it_behaves_like 'overflow stuff'
2017-08-17 22:00:37 +05:30
describe '#overflow?' do
subject { super().overflow? }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to be_falsey }
end
describe '#empty?' do
subject { super().empty? }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to be_falsey }
end
describe '#real_size' do
subject { super().real_size }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to eq('3') }
end
2017-09-10 17:25:29 +05:30
describe '#size' do
it { expect(subject.size).to eq(3) }
it 'does not change after peeking' do
subject.any?
expect(subject.size).to eq(3)
end
end
2017-08-17 22:00:37 +05:30
2019-12-04 20:38:33 +05:30
describe '#line_count' do
subject { super().line_count }
2019-12-21 20:55:43 +05:30
2019-12-04 20:38:33 +05:30
it { is_expected.to eq file_count * line_count }
end
2017-08-17 22:00:37 +05:30
context 'when limiting is disabled' do
2017-09-10 17:25:29 +05:30
let(:limits) { false }
2021-04-29 21:17:54 +05:30
let(:overflow_max_bytes) { false }
let(:overflow_max_files) { false }
let(:overflow_max_lines) { false }
it_behaves_like 'overflow stuff'
2017-08-17 22:00:37 +05:30
describe '#overflow?' do
subject { super().overflow? }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to be_falsey }
end
describe '#empty?' do
subject { super().empty? }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to be_falsey }
end
describe '#real_size' do
subject { super().real_size }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to eq('3') }
end
2017-09-10 17:25:29 +05:30
describe '#size' do
it { expect(subject.size).to eq(3) }
it 'does not change after peeking' do
subject.any?
expect(subject.size).to eq(3)
end
end
2019-12-04 20:38:33 +05:30
describe '#line_count' do
subject { super().line_count }
2019-12-21 20:55:43 +05:30
2019-12-04 20:38:33 +05:30
it { is_expected.to eq file_count * line_count }
end
2017-08-17 22:00:37 +05:30
end
end
context 'and too many lines' do
let(:line_count) { 1000 }
2021-04-29 21:17:54 +05:30
let(:overflow_max_lines) { true }
it_behaves_like 'overflow stuff'
2017-08-17 22:00:37 +05:30
describe '#overflow?' do
subject { super().overflow? }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to be_truthy }
end
describe '#empty?' do
subject { super().empty? }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to be_falsey }
end
describe '#real_size' do
subject { super().real_size }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to eq('0+') }
end
2019-12-04 20:38:33 +05:30
describe '#line_count' do
subject { super().line_count }
2019-12-21 20:55:43 +05:30
2019-12-04 20:38:33 +05:30
it { is_expected.to eq 1000 }
end
2017-08-17 22:00:37 +05:30
it { expect(subject.size).to eq(0) }
context 'when limiting is disabled' do
2017-09-10 17:25:29 +05:30
let(:limits) { false }
2021-04-29 21:17:54 +05:30
let(:overflow_max_bytes) { false }
let(:overflow_max_files) { false }
let(:overflow_max_lines) { false }
it_behaves_like 'overflow stuff'
2017-08-17 22:00:37 +05:30
describe '#overflow?' do
subject { super().overflow? }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to be_falsey }
end
describe '#empty?' do
subject { super().empty? }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to be_falsey }
end
describe '#real_size' do
subject { super().real_size }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to eq('3') }
end
2019-12-04 20:38:33 +05:30
describe '#line_count' do
subject { super().line_count }
2019-12-21 20:55:43 +05:30
2019-12-04 20:38:33 +05:30
it { is_expected.to eq file_count * line_count }
end
2017-08-17 22:00:37 +05:30
it { expect(subject.size).to eq(3) }
end
end
end
context 'adding too many files' do
let(:file_count) { 11 }
2021-04-29 21:17:54 +05:30
let(:overflow_max_files) { true }
2017-08-17 22:00:37 +05:30
context 'and few enough lines' do
let(:line_count) { 1 }
2021-04-29 21:17:54 +05:30
it_behaves_like 'overflow stuff'
2017-08-17 22:00:37 +05:30
describe '#overflow?' do
subject { super().overflow? }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to be_truthy }
end
describe '#empty?' do
subject { super().empty? }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to be_falsey }
end
describe '#real_size' do
subject { super().real_size }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to eq('10+') }
end
2019-12-04 20:38:33 +05:30
describe '#line_count' do
subject { super().line_count }
2019-12-21 20:55:43 +05:30
2019-12-04 20:38:33 +05:30
it { is_expected.to eq 10 }
end
2017-08-17 22:00:37 +05:30
it { expect(subject.size).to eq(10) }
context 'when limiting is disabled' do
2017-09-10 17:25:29 +05:30
let(:limits) { false }
2021-04-29 21:17:54 +05:30
let(:overflow_max_bytes) { false }
let(:overflow_max_files) { false }
let(:overflow_max_lines) { false }
it_behaves_like 'overflow stuff'
2017-08-17 22:00:37 +05:30
describe '#overflow?' do
subject { super().overflow? }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to be_falsey }
end
describe '#empty?' do
subject { super().empty? }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to be_falsey }
end
describe '#real_size' do
subject { super().real_size }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to eq('11') }
end
2019-12-04 20:38:33 +05:30
describe '#line_count' do
subject { super().line_count }
2019-12-21 20:55:43 +05:30
2019-12-04 20:38:33 +05:30
it { is_expected.to eq file_count * line_count }
end
2017-08-17 22:00:37 +05:30
it { expect(subject.size).to eq(11) }
end
end
context 'and too many lines' do
let(:line_count) { 30 }
2021-04-29 21:17:54 +05:30
let(:overflow_max_lines) { true }
let(:overflow_max_files) { false }
it_behaves_like 'overflow stuff'
2017-08-17 22:00:37 +05:30
describe '#overflow?' do
subject { super().overflow? }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to be_truthy }
end
describe '#empty?' do
subject { super().empty? }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to be_falsey }
end
describe '#real_size' do
subject { super().real_size }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to eq('3+') }
end
2019-12-04 20:38:33 +05:30
describe '#line_count' do
subject { super().line_count }
2019-12-21 20:55:43 +05:30
2019-12-04 20:38:33 +05:30
it { is_expected.to eq 120 }
end
2017-08-17 22:00:37 +05:30
it { expect(subject.size).to eq(3) }
context 'when limiting is disabled' do
2017-09-10 17:25:29 +05:30
let(:limits) { false }
2021-04-29 21:17:54 +05:30
let(:overflow_max_bytes) { false }
let(:overflow_max_files) { false }
let(:overflow_max_lines) { false }
it_behaves_like 'overflow stuff'
2017-08-17 22:00:37 +05:30
describe '#overflow?' do
subject { super().overflow? }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to be_falsey }
end
describe '#empty?' do
subject { super().empty? }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to be_falsey }
end
describe '#real_size' do
subject { super().real_size }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to eq('11') }
end
2019-12-04 20:38:33 +05:30
describe '#line_count' do
subject { super().line_count }
2019-12-21 20:55:43 +05:30
2019-12-04 20:38:33 +05:30
it { is_expected.to eq file_count * line_count }
end
2017-08-17 22:00:37 +05:30
it { expect(subject.size).to eq(11) }
end
end
end
context 'adding exactly the maximum number of files' do
let(:file_count) { 10 }
context 'and few enough lines' do
let(:line_count) { 1 }
2021-04-29 21:17:54 +05:30
it_behaves_like 'overflow stuff'
2017-08-17 22:00:37 +05:30
describe '#overflow?' do
subject { super().overflow? }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to be_falsey }
end
describe '#empty?' do
subject { super().empty? }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to be_falsey }
end
describe '#real_size' do
subject { super().real_size }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to eq('10') }
end
2019-12-04 20:38:33 +05:30
describe '#line_count' do
subject { super().line_count }
2019-12-21 20:55:43 +05:30
2019-12-04 20:38:33 +05:30
it { is_expected.to eq file_count * line_count }
end
2017-08-17 22:00:37 +05:30
it { expect(subject.size).to eq(10) }
end
end
context 'adding too many bytes' do
let(:file_count) { 10 }
let(:line_length) { 5200 }
2021-04-29 21:17:54 +05:30
let(:overflow_max_bytes) { true }
it_behaves_like 'overflow stuff'
2017-08-17 22:00:37 +05:30
describe '#overflow?' do
subject { super().overflow? }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to be_truthy }
end
describe '#empty?' do
subject { super().empty? }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to be_falsey }
end
describe '#real_size' do
subject { super().real_size }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to eq('9+') }
end
2019-12-04 20:38:33 +05:30
describe '#line_count' do
subject { super().line_count }
2019-12-21 20:55:43 +05:30
2019-12-04 20:38:33 +05:30
it { is_expected.to eq file_count * line_count }
end
2017-08-17 22:00:37 +05:30
it { expect(subject.size).to eq(9) }
context 'when limiting is disabled' do
2017-09-10 17:25:29 +05:30
let(:limits) { false }
2021-04-29 21:17:54 +05:30
let(:overflow_max_bytes) { false }
let(:overflow_max_files) { false }
let(:overflow_max_lines) { false }
it_behaves_like 'overflow stuff'
2017-08-17 22:00:37 +05:30
describe '#overflow?' do
subject { super().overflow? }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to be_falsey }
end
describe '#empty?' do
subject { super().empty? }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to be_falsey }
end
describe '#real_size' do
subject { super().real_size }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to eq('10') }
end
2019-12-04 20:38:33 +05:30
describe '#line_count' do
subject { super().line_count }
2019-12-21 20:55:43 +05:30
2019-12-04 20:38:33 +05:30
it { is_expected.to eq file_count * line_count }
end
2017-08-17 22:00:37 +05:30
it { expect(subject.size).to eq(10) }
end
end
end
describe 'empty collection' do
subject { Gitlab::Git::DiffCollection.new([]) }
2021-04-29 21:17:54 +05:30
it_behaves_like 'overflow stuff'
2017-08-17 22:00:37 +05:30
describe '#overflow?' do
subject { super().overflow? }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to be_falsey }
end
describe '#empty?' do
subject { super().empty? }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to be_truthy }
end
describe '#size' do
subject { super().size }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to eq(0) }
end
describe '#real_size' do
subject { super().real_size }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to eq('0')}
end
2019-12-04 20:38:33 +05:30
describe '#line_count' do
subject { super().line_count }
2019-12-21 20:55:43 +05:30
2019-12-04 20:38:33 +05:30
it { is_expected.to eq 0 }
end
2017-08-17 22:00:37 +05:30
end
describe '#each' do
context 'when diff are too large' do
let(:collection) do
Gitlab::Git::DiffCollection.new([{ diff: 'a' * 204800 }])
end
it 'yields Diff instances even when they are too large' do
2017-09-10 17:25:29 +05:30
expect { |b| collection.each(&b) }
.to yield_with_args(an_instance_of(Gitlab::Git::Diff))
2017-08-17 22:00:37 +05:30
end
it 'prunes diffs that are too large' do
diff = nil
collection.each do |d|
diff = d
end
expect(diff.diff).to eq('')
end
end
context 'when diff is quite large will collapse by default' do
2018-03-17 18:26:18 +05:30
let(:iterator) { [{ diff: 'a' * 20480 }] }
2017-08-17 22:00:37 +05:30
context 'when no collapse is set' do
2017-09-10 17:25:29 +05:30
let(:expanded) { true }
2017-08-17 22:00:37 +05:30
it 'yields Diff instances even when they are quite big' do
2017-09-10 17:25:29 +05:30
expect { |b| subject.each(&b) }
.to yield_with_args(an_instance_of(Gitlab::Git::Diff))
2017-08-17 22:00:37 +05:30
end
it 'does not prune diffs' do
diff = nil
subject.each do |d|
diff = d
end
expect(diff.diff).not_to eq('')
end
end
context 'when no collapse is unset' do
2017-09-10 17:25:29 +05:30
let(:expanded) { false }
2017-08-17 22:00:37 +05:30
it 'yields Diff instances even when they are quite big' do
2017-09-10 17:25:29 +05:30
expect { |b| subject.each(&b) }
.to yield_with_args(an_instance_of(Gitlab::Git::Diff))
2017-08-17 22:00:37 +05:30
end
2021-01-03 14:25:43 +05:30
context 'single-file collections' do
it 'does not prune diffs' do
diff = nil
2017-08-17 22:00:37 +05:30
2021-01-03 14:25:43 +05:30
subject.each do |d|
diff = d
end
expect(diff.diff).not_to eq('')
2017-08-17 22:00:37 +05:30
end
2021-01-03 14:25:43 +05:30
end
context 'multi-file collections' do
let(:iterator) { [{ diff: 'b' }, { diff: 'a' * 20480 }]}
it 'prunes diffs that are quite big' do
diff = nil
2017-08-17 22:00:37 +05:30
2021-01-03 14:25:43 +05:30
subject.each do |d|
diff = d
end
expect(diff.diff).to eq('')
end
2017-08-17 22:00:37 +05:30
end
context 'when go over safe limits on files' do
let(:iterator) { [fake_diff(1, 1)] * 4 }
2018-03-17 18:26:18 +05:30
before do
2021-01-03 14:25:43 +05:30
allow(Gitlab::Git::DiffCollection)
.to receive(:default_limits)
.and_return({ max_files: 2, max_lines: max_lines })
2017-08-17 22:00:37 +05:30
end
2021-04-29 21:17:54 +05:30
it 'prunes diffs by default even little ones and sets collapsed_safe_files true' do
2017-08-17 22:00:37 +05:30
subject.each_with_index do |d, i|
if i < 2
expect(d.diff).not_to eq('')
else # 90 lines
expect(d.diff).to eq('')
end
end
2021-04-29 21:17:54 +05:30
expect(subject.collapsed_safe_files?).to eq(true)
2017-08-17 22:00:37 +05:30
end
end
context 'when go over safe limits on lines' do
let(:iterator) do
[
fake_diff(1, 45),
fake_diff(1, 45),
fake_diff(1, 20480),
fake_diff(1, 1)
]
end
2018-03-17 18:26:18 +05:30
before do
2021-01-03 14:25:43 +05:30
allow(Gitlab::Git::DiffCollection)
.to receive(:default_limits)
.and_return({ max_files: max_files, max_lines: 80 })
2017-08-17 22:00:37 +05:30
end
2021-04-29 21:17:54 +05:30
it 'prunes diffs by default even little ones and sets collapsed_safe_lines true' do
2017-08-17 22:00:37 +05:30
subject.each_with_index do |d, i|
if i < 2
expect(d.diff).not_to eq('')
else # 90 lines
expect(d.diff).to eq('')
end
end
2021-04-29 21:17:54 +05:30
expect(subject.collapsed_safe_lines?).to eq(true)
2017-08-17 22:00:37 +05:30
end
end
context 'when go over safe limits on bytes' do
let(:iterator) do
[
2021-04-29 21:17:54 +05:30
fake_diff(5, 10),
fake_diff(5000, 10),
fake_diff(5, 10),
fake_diff(5, 10)
2017-08-17 22:00:37 +05:30
]
end
2018-03-17 18:26:18 +05:30
before do
2021-04-29 21:17:54 +05:30
allow(Gitlab::CurrentSettings).to receive(:diff_max_patch_bytes).and_return(1.megabyte)
2021-01-03 14:25:43 +05:30
allow(Gitlab::Git::DiffCollection)
.to receive(:default_limits)
2021-04-29 21:17:54 +05:30
.and_return({ max_files: 4, max_lines: 3000 })
2017-08-17 22:00:37 +05:30
end
2021-04-29 21:17:54 +05:30
it 'prunes diffs by default even little ones and sets collapsed_safe_bytes true' do
2017-08-17 22:00:37 +05:30
subject.each_with_index do |d, i|
if i < 2
expect(d.diff).not_to eq('')
else # > 80 bytes
expect(d.diff).to eq('')
end
end
2021-04-29 21:17:54 +05:30
expect(subject.collapsed_safe_bytes?).to eq(true)
2017-08-17 22:00:37 +05:30
end
end
end
context 'when limiting is disabled' do
2017-09-10 17:25:29 +05:30
let(:limits) { false }
2017-08-17 22:00:37 +05:30
it 'yields Diff instances even when they are quite big' do
2017-09-10 17:25:29 +05:30
expect { |b| subject.each(&b) }
.to yield_with_args(an_instance_of(Gitlab::Git::Diff))
2017-08-17 22:00:37 +05:30
end
it 'does not prune diffs' do
diff = nil
subject.each do |d|
diff = d
end
expect(diff.diff).not_to eq('')
end
end
end
2019-12-21 20:55:43 +05:30
context 'when offset_index is given' do
subject do
Gitlab::Git::DiffCollection.new(
iterator,
max_files: max_files,
max_lines: max_lines,
limits: limits,
offset_index: 2,
expanded: expanded
)
end
def diff(raw)
raw['diff']
end
let(:iterator) do
[
fake_diff(1, 1),
fake_diff(2, 2),
fake_diff(3, 3),
fake_diff(4, 4)
]
end
it 'does not yield diffs before the offset' do
expect(subject.to_a.map(&:diff)).to eq(
[
diff(fake_diff(3, 3)),
diff(fake_diff(4, 4))
]
)
end
context 'when go over safe limits on bytes' do
let(:iterator) do
[
fake_diff(1, 10), # 10
fake_diff(1, 10), # 20
fake_diff(1, 15), # 35
fake_diff(1, 20), # 55
fake_diff(1, 45), # 100 - limit hit
fake_diff(1, 45),
fake_diff(1, 20480),
fake_diff(1, 1)
]
end
before do
2021-01-03 14:25:43 +05:30
allow(Gitlab::Git::DiffCollection)
.to receive(:default_limits)
.and_return({ max_files: max_files, max_lines: 80 })
2019-12-21 20:55:43 +05:30
end
it 'considers size of diffs before the offset for prunning' do
expect(subject.to_a.map(&:diff)).to eq(
[
diff(fake_diff(1, 15)),
diff(fake_diff(1, 20))
]
)
end
end
end
2017-08-17 22:00:37 +05:30
end
def fake_diff(line_length, line_count)
{ 'diff' => "#{'a' * line_length}\n" * line_count }
end
end