summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/config_checker/external_database_checker_spec.rb
blob: d86d132c237667dee8e50ec23a77289ba223fe09 (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# frozen_string_literal: true

require 'spec_helper'

describe Gitlab::ConfigChecker::ExternalDatabaseChecker do
  describe '#check' do
    subject { described_class.check }

    context 'database version is not deprecated' do
      before do
        allow(described_class).to receive(:db_version_deprecated?).and_return(false)
      end

      it { is_expected.to be_empty }
    end

    context 'database version is deprecated' do
      before do
        allow(described_class).to receive(:db_version_deprecated?).and_return(true)
      end

      let(:notice_deprecated_database) do
        {
          type: 'warning',
            message: _('Note that PostgreSQL 11 will become the minimum required PostgreSQL version in GitLab 13.0 (May 2020). '\
                     'PostgreSQL 9.6 and PostgreSQL 10 will no longer be supported in GitLab 13.0. '\
                     'Please consider upgrading your PostgreSQL version (%{db_version}) soon.') % { db_version: Gitlab::Database.version.to_s }
        }
      end

      it 'reports deprecated database notices' do
        is_expected.to contain_exactly(notice_deprecated_database)
      end
    end
  end

  describe '#db_version_deprecated' do
    subject { described_class.db_version_deprecated? }

    context 'database version is not deprecated' do
      before do
        allow(Gitlab::Database).to receive(:version).and_return(11)
      end

      it { is_expected.to be false }
    end

    context 'database version is deprecated' do
      before do
        allow(Gitlab::Database).to receive(:version).and_return(10)
      end

      it { is_expected.to be true }
    end
  end
end