2020-03-31 18:07:42 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 18:09:03 +00:00
|
|
|
RSpec.describe Gitlab::RepositorySizeChecker do
|
2020-10-19 12:09:20 +00:00
|
|
|
let_it_be(:namespace) { nil }
|
2021-04-21 00:11:06 +00:00
|
|
|
|
2020-03-31 18:07:42 +00:00
|
|
|
let(:current_size) { 0 }
|
|
|
|
let(:limit) { 50 }
|
|
|
|
let(:enabled) { true }
|
|
|
|
|
|
|
|
subject do
|
|
|
|
described_class.new(
|
2020-10-19 12:09:20 +00:00
|
|
|
current_size_proc: -> { current_size.megabytes },
|
|
|
|
limit: limit.megabytes,
|
|
|
|
namespace: namespace,
|
2020-03-31 18:07:42 +00:00
|
|
|
enabled: enabled
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#enabled?' do
|
|
|
|
context 'when enabled' do
|
|
|
|
it 'returns true' do
|
2020-10-19 12:09:20 +00:00
|
|
|
expect(subject.enabled?).to eq(true)
|
2020-03-31 18:07:42 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when limit is zero' do
|
|
|
|
let(:limit) { 0 }
|
|
|
|
|
|
|
|
it 'returns false' do
|
2020-10-19 12:09:20 +00:00
|
|
|
expect(subject.enabled?).to eq(false)
|
2020-03-31 18:07:42 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#changes_will_exceed_size_limit?' do
|
|
|
|
let(:current_size) { 49 }
|
|
|
|
|
|
|
|
it 'returns true when changes go over' do
|
2020-10-19 12:09:20 +00:00
|
|
|
expect(subject.changes_will_exceed_size_limit?(2.megabytes)).to eq(true)
|
2020-03-31 18:07:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns false when changes do not go over' do
|
2020-10-19 12:09:20 +00:00
|
|
|
expect(subject.changes_will_exceed_size_limit?(1.megabytes)).to eq(false)
|
2020-03-31 18:07:42 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#above_size_limit?' do
|
2020-10-12 18:08:31 +00:00
|
|
|
include_examples 'checker size above limit'
|
|
|
|
include_examples 'checker size not over limit'
|
2020-03-31 18:07:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe '#exceeded_size' do
|
2020-10-12 18:08:31 +00:00
|
|
|
include_examples 'checker size exceeded'
|
2020-03-31 18:07:42 +00:00
|
|
|
end
|
2020-11-17 06:09:39 +00:00
|
|
|
|
|
|
|
describe '#additional_repo_storage_available?' do
|
|
|
|
it 'returns false' do
|
|
|
|
expect(subject.additional_repo_storage_available?).to eq(false)
|
|
|
|
end
|
|
|
|
end
|
2020-03-31 18:07:42 +00:00
|
|
|
end
|