debian-mirror-gitlab/spec/support/shared_examples/lib/gitlab/repository_size_checker_shared_examples.rb

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

75 lines
1.8 KiB
Ruby
Raw Normal View History

2021-01-03 14:25:43 +05:30
# frozen_string_literal: true
RSpec.shared_examples 'checker size above limit' do
context 'when size is above the limit' do
let(:current_size) { 100 }
it 'returns true' do
expect(subject.above_size_limit?).to eq(true)
end
end
end
RSpec.shared_examples 'checker size not over limit' do
it 'returns false when not over the limit' do
expect(subject.above_size_limit?).to eq(false)
end
end
RSpec.shared_examples 'checker size exceeded' do
2021-01-29 00:20:46 +05:30
context 'when no change size provided' do
context 'when current size is below the limit' do
let(:current_size) { limit - 1 }
2021-01-03 14:25:43 +05:30
2021-01-29 00:20:46 +05:30
it 'returns zero' do
expect(subject.exceeded_size).to eq(0)
end
2021-01-03 14:25:43 +05:30
end
2021-01-29 00:20:46 +05:30
context 'when current size is equal to the limit' do
let(:current_size) { limit }
2021-01-03 14:25:43 +05:30
2021-01-29 00:20:46 +05:30
it 'returns zero' do
expect(subject.exceeded_size).to eq(0)
end
2021-01-03 14:25:43 +05:30
end
2021-01-29 00:20:46 +05:30
context 'when current size is over the limit' do
let(:current_size) { limit + 1 }
let(:total_repository_size_excess) { 1 }
2021-01-03 14:25:43 +05:30
2021-01-29 00:20:46 +05:30
it 'returns a positive number' do
expect(subject.exceeded_size).to eq(1.megabyte)
end
2021-01-03 14:25:43 +05:30
end
end
2021-01-29 00:20:46 +05:30
context 'when a change size is provided' do
let(:change_size) { 1.megabyte }
context 'when change size will be over the limit' do
let(:current_size) { limit }
it 'returns a positive number' do
expect(subject.exceeded_size(change_size)).to eq(1.megabyte)
end
end
context 'when change size will be at the limit' do
let(:current_size) { limit - 1 }
it 'returns zero' do
expect(subject.exceeded_size(change_size)).to eq(0)
end
end
context 'when change size will be under the limit' do
let(:current_size) { limit - 2 }
2021-01-03 14:25:43 +05:30
2021-01-29 00:20:46 +05:30
it 'returns zero' do
expect(subject.exceeded_size(change_size)).to eq(0)
end
2021-01-03 14:25:43 +05:30
end
end
end