diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-23 18:27:09 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-23 18:27:09 +0000 |
commit | bcc70301531b6c3118120173389f2aaa7452bf11 (patch) | |
tree | 161f1ee56e15ec9e59f48c5e1a9cb86b62469a49 /spec/lib | |
parent | d47fc5085a706ab37d038636c9d5934da69853f0 (diff) | |
download | gitlab-ce-bcc70301531b6c3118120173389f2aaa7452bf11.tar.gz |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/config_checker/external_database_checker_spec.rb | 47 | ||||
-rw-r--r-- | spec/lib/gitlab/database_spec.rb | 20 |
2 files changed, 59 insertions, 8 deletions
diff --git a/spec/lib/gitlab/config_checker/external_database_checker_spec.rb b/spec/lib/gitlab/config_checker/external_database_checker_spec.rb index 316696bc584..712903e020a 100644 --- a/spec/lib/gitlab/config_checker/external_database_checker_spec.rb +++ b/spec/lib/gitlab/config_checker/external_database_checker_spec.rb @@ -36,9 +36,23 @@ RSpec.describe Gitlab::ConfigChecker::ExternalDatabaseChecker do allow(Gitlab::Database).to receive(:postgresql_upcoming_deprecation?).and_return(true) end - 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))) + context 'inside the deprecation notice window' do + before do + allow(Gitlab::Database).to receive(:within_deprecation_notice_window?).and_return(true) + end + + 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 + end + + 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 end @@ -48,11 +62,28 @@ RSpec.describe Gitlab::ConfigChecker::ExternalDatabaseChecker do allow(Gitlab::Database).to receive(:postgresql_upcoming_deprecation?).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)) - ) + 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 + end + + 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 end end diff --git a/spec/lib/gitlab/database_spec.rb b/spec/lib/gitlab/database_spec.rb index cd009f955af..47d2cb05240 100644 --- a/spec/lib/gitlab/database_spec.rb +++ b/spec/lib/gitlab/database_spec.rb @@ -129,6 +129,26 @@ RSpec.describe Gitlab::Database do end end + describe '.within_deprecation_notice_window?' do + using RSpec::Parameterized::TableSyntax + + where(:case_name, :days, :result) do + 'outside window' | Gitlab::Database::DEPRECATION_WINDOW_DAYS + 1 | false + 'equal to window' | Gitlab::Database::DEPRECATION_WINDOW_DAYS | true + 'within window' | Gitlab::Database::DEPRECATION_WINDOW_DAYS - 1 | true + end + + with_them do + it "returns #{params[:result]} when #{params[:case_name]}" do + allow(Date) + .to receive(:today) + .and_return Date.parse(Gitlab::Database::UPCOMING_POSTGRES_VERSION_DETAILS[:gl_version_date]) - days + + expect(described_class.within_deprecation_notice_window?).to eq(result) + end + end + end + describe '.check_postgres_version_and_print_warning' do subject { described_class.check_postgres_version_and_print_warning } |