Welcome to mirror list, hosted at ThFree Co, Russian Federation.

pg_depend_spec.rb « database « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ff5169ebabf290e4013404ee19e4a30b09d12209 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Database::PgDepend, type: :model, feature_category: :database do
  let(:connection) { described_class.connection }

  describe '.from_pg_extension' do
    subject { described_class.from_pg_extension('VIEW') }

    context 'when having views as dependency' do
      before do
        connection.execute('CREATE EXTENSION IF NOT EXISTS pg_stat_statements;')
      end

      it 'returns pg_stat_statements' do
        expected_views = ['pg_stat_statements']

        if Gitlab::Database::Reflection.new(described_class).version.to_f >= 14
          expected_views << 'pg_stat_statements_info' # View added by pg_stat_statements starting in postgres 14
        end

        expect(subject.pluck('relname')).to match_array(expected_views)
      end
    end
  end
end