debian-mirror-gitlab/spec/lib/gitlab/config_checker/external_database_checker_spec.rb

91 lines
3.5 KiB
Ruby
Raw Normal View History

2020-05-24 23:13:21 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe Gitlab::ConfigChecker::ExternalDatabaseChecker do
2020-05-24 23:13:21 +05:30
describe '#check' do
subject { described_class.check }
2020-07-28 23:09:34 +05:30
let_it_be(:deprecation_warning) { "Please upgrade" }
let_it_be(:upcoming_deprecation_warning) { "Please consider upgrading" }
context 'when database meets minimum version and there is no upcoming deprecation' do
2020-05-24 23:13:21 +05:30
before do
2020-07-28 23:09:34 +05:30
allow(Gitlab::Database).to receive(:postgresql_minimum_supported_version?).and_return(true)
allow(Gitlab::Database).to receive(:postgresql_upcoming_deprecation?).and_return(false)
2020-05-24 23:13:21 +05:30
end
it { is_expected.to be_empty }
end
2020-07-28 23:09:34 +05:30
context 'when database does not meet minimum version and there is no upcoming deprecation' do
2020-05-24 23:13:21 +05:30
before do
2020-07-28 23:09:34 +05:30
allow(Gitlab::Database).to receive(:postgresql_minimum_supported_version?).and_return(false)
allow(Gitlab::Database).to receive(:postgresql_upcoming_deprecation?).and_return(false)
2020-05-24 23:13:21 +05:30
end
2020-07-28 23:09:34 +05:30
it 'only returns notice about deprecated database version' do
is_expected.to include(a_hash_including(message: include(deprecation_warning)))
is_expected.not_to include(a_hash_including(message: include(upcoming_deprecation_warning)))
2020-05-24 23:13:21 +05:30
end
2020-07-28 23:09:34 +05:30
end
2020-05-24 23:13:21 +05:30
2020-07-28 23:09:34 +05:30
context 'when database meets minimum version and there is an upcoming deprecation' do
before do
allow(Gitlab::Database).to receive(:postgresql_minimum_supported_version?).and_return(true)
allow(Gitlab::Database).to receive(:postgresql_upcoming_deprecation?).and_return(true)
2020-05-24 23:13:21 +05:30
end
2020-07-28 23:09:34 +05:30
context 'inside the deprecation notice window' do
before do
allow(Gitlab::Database).to receive(:within_deprecation_notice_window?).and_return(true)
end
2020-05-24 23:13:21 +05:30
2020-07-28 23:09:34 +05:30
it 'only returns notice about an upcoming deprecation' do
is_expected.to include(a_hash_including(message: include(upcoming_deprecation_warning)))
is_expected.not_to include(a_hash_including(message: include(deprecation_warning)))
end
2020-05-24 23:13:21 +05:30
end
2020-07-28 23:09:34 +05:30
context 'outside the deprecation notice window' do
before do
allow(Gitlab::Database).to receive(:within_deprecation_notice_window?).and_return(false)
end
it { is_expected.to be_empty }
end
2020-05-24 23:13:21 +05:30
end
2020-07-28 23:09:34 +05:30
context 'when database does not meet minimum version and there is an upcoming deprecation' do
2020-05-24 23:13:21 +05:30
before do
2020-07-28 23:09:34 +05:30
allow(Gitlab::Database).to receive(:postgresql_minimum_supported_version?).and_return(false)
allow(Gitlab::Database).to receive(:postgresql_upcoming_deprecation?).and_return(true)
end
context 'inside the deprecation notice window' do
before do
allow(Gitlab::Database).to receive(:within_deprecation_notice_window?).and_return(true)
end
it 'returns notice about deprecated database version and an upcoming deprecation' do
is_expected.to include(
a_hash_including(message: include(deprecation_warning)),
a_hash_including(message: include(upcoming_deprecation_warning))
)
end
2020-05-24 23:13:21 +05:30
end
2020-07-28 23:09:34 +05:30
context 'outside the deprecation notice window' do
before do
allow(Gitlab::Database).to receive(:within_deprecation_notice_window?).and_return(false)
end
it 'only returns notice about deprecated database version' do
is_expected.to include(a_hash_including(message: include(deprecation_warning)))
is_expected.not_to include(a_hash_including(message: include(upcoming_deprecation_warning)))
end
end
2020-05-24 23:13:21 +05:30
end
end
end