debian-mirror-gitlab/spec/lib/gitlab/database/postgres_autovacuum_activity_spec.rb

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

33 lines
904 B
Ruby
Raw Normal View History

2022-08-13 15:12:31 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-03-17 16:20:25 +05:30
RSpec.describe Gitlab::Database::PostgresAutovacuumActivity, type: :model, feature_category: :database do
2022-08-13 15:12:31 +05:30
include Database::DatabaseHelpers
it { is_expected.to be_a Gitlab::Database::SharedModel }
describe '.for_tables' do
subject { described_class.for_tables(tables) }
let(:tables) { %w[foo test] }
before do
2023-03-17 16:20:25 +05:30
swapout_view_for_table(:postgres_autovacuum_activity, connection: ApplicationRecord.connection)
2022-08-13 15:12:31 +05:30
# unrelated
create(:postgres_autovacuum_activity, table: 'bar')
tables.each do |table|
create(:postgres_autovacuum_activity, table: table)
end
expect(Gitlab::Database::LoadBalancing::Session.current).to receive(:use_primary).and_yield
end
it 'returns autovacuum activity for queries tables' do
expect(subject.map(&:table).sort).to eq(tables)
end
end
end