summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/database/postgres_index_bloat_estimate_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-12-17 11:59:07 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-12-17 11:59:07 +0000
commit8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch)
tree544930fb309b30317ae9797a9683768705d664c4 /spec/lib/gitlab/database/postgres_index_bloat_estimate_spec.rb
parent4b1de649d0168371549608993deac953eb692019 (diff)
downloadgitlab-ce-8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca.tar.gz
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'spec/lib/gitlab/database/postgres_index_bloat_estimate_spec.rb')
-rw-r--r--spec/lib/gitlab/database/postgres_index_bloat_estimate_spec.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/lib/gitlab/database/postgres_index_bloat_estimate_spec.rb b/spec/lib/gitlab/database/postgres_index_bloat_estimate_spec.rb
new file mode 100644
index 00000000000..da4422bd442
--- /dev/null
+++ b/spec/lib/gitlab/database/postgres_index_bloat_estimate_spec.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Gitlab::Database::PostgresIndexBloatEstimate do
+ before do
+ ActiveRecord::Base.connection.execute(<<~SQL)
+ ANALYZE schema_migrations
+ SQL
+ end
+
+ subject { described_class.find(identifier) }
+
+ let(:identifier) { 'public.schema_migrations_pkey' }
+
+ describe '#bloat_size' do
+ it 'returns the bloat size in bytes' do
+ # We cannot reach much more about the bloat size estimate here
+ expect(subject.bloat_size).to be >= 0
+ end
+ end
+
+ describe '#bloat_size_bytes' do
+ it 'is an alias of #bloat_size' do
+ expect(subject.bloat_size_bytes).to eq(subject.bloat_size)
+ end
+ end
+
+ describe '#index' do
+ it 'belongs to a PostgresIndex' do
+ expect(subject.index.identifier).to eq(identifier)
+ end
+ end
+end