2020-05-12 18:07:54 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 18:09:03 +00:00
|
|
|
RSpec.describe Gitlab::ConfigChecker::ExternalDatabaseChecker do
|
2020-05-12 18:07:54 +00:00
|
|
|
describe '#check' do
|
|
|
|
subject { described_class.check }
|
|
|
|
|
2020-08-21 00:10:44 +00:00
|
|
|
context 'when database meets minimum supported version' do
|
2020-05-12 18:07:54 +00:00
|
|
|
before do
|
2021-11-15 15:10:57 +00:00
|
|
|
allow(ApplicationRecord.database).to receive(:postgresql_minimum_supported_version?).and_return(true)
|
2020-05-12 18:07:54 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it { is_expected.to be_empty }
|
|
|
|
end
|
|
|
|
|
2020-08-21 00:10:44 +00:00
|
|
|
context 'when database does not meet minimum supported version' do
|
2020-05-12 18:07:54 +00:00
|
|
|
before do
|
2021-11-15 15:10:57 +00:00
|
|
|
allow(ApplicationRecord.database).to receive(:postgresql_minimum_supported_version?).and_return(false)
|
2020-05-12 18:07:54 +00:00
|
|
|
end
|
|
|
|
|
2020-08-21 00:10:44 +00:00
|
|
|
let(:notice_deprecated_database) do
|
|
|
|
{
|
|
|
|
type: 'warning',
|
|
|
|
message: _('You are using PostgreSQL %{pg_version_current}, but PostgreSQL ' \
|
|
|
|
'%{pg_version_minimum} is required for this version of GitLab. ' \
|
|
|
|
'Please upgrade your environment to a supported PostgreSQL version, ' \
|
|
|
|
'see %{pg_requirements_url} for details.') % {
|
2021-11-15 15:10:57 +00:00
|
|
|
pg_version_current: ApplicationRecord.database.version,
|
2020-08-21 00:10:44 +00:00
|
|
|
pg_version_minimum: Gitlab::Database::MINIMUM_POSTGRES_VERSION,
|
|
|
|
pg_requirements_url: '<a href="https://docs.gitlab.com/ee/install/requirements.html#database">database requirements</a>'
|
|
|
|
}
|
|
|
|
}
|
2020-05-12 18:07:54 +00:00
|
|
|
end
|
|
|
|
|
2020-08-21 00:10:44 +00:00
|
|
|
it 'reports deprecated database notice' do
|
|
|
|
is_expected.to contain_exactly(notice_deprecated_database)
|
2020-07-14 21:09:03 +00:00
|
|
|
end
|
2020-05-12 18:07:54 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|