diff options
Diffstat (limited to 'spec/lib/gitlab/database/postgres_index_spec.rb')
-rw-r--r-- | spec/lib/gitlab/database/postgres_index_spec.rb | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/spec/lib/gitlab/database/postgres_index_spec.rb b/spec/lib/gitlab/database/postgres_index_spec.rb index d65b638f7bc..2fda9b85c5a 100644 --- a/spec/lib/gitlab/database/postgres_index_spec.rb +++ b/spec/lib/gitlab/database/postgres_index_spec.rb @@ -27,7 +27,7 @@ RSpec.describe Gitlab::Database::PostgresIndex do expect(described_class.regular).to all(have_attributes(unique: false)) end - it 'only non partitioned indexes ' do + it 'only non partitioned indexes' do expect(described_class.regular).to all(have_attributes(partitioned: false)) end @@ -46,9 +46,24 @@ RSpec.describe Gitlab::Database::PostgresIndex do end end - describe '.random_few' do - it 'limits to two records by default' do - expect(described_class.random_few(2).size).to eq(2) + describe '#bloat_size' do + subject { build(:postgres_index, bloat_estimate: bloat_estimate) } + + let(:bloat_estimate) { build(:postgres_index_bloat_estimate) } + let(:bloat_size) { double } + + it 'returns the bloat size from the estimate' do + expect(bloat_estimate).to receive(:bloat_size).and_return(bloat_size) + + expect(subject.bloat_size).to eq(bloat_size) + end + + context 'without a bloat estimate available' do + let(:bloat_estimate) { nil } + + it 'returns 0' do + expect(subject.bloat_size).to eq(0) + end end end |