diff options
Diffstat (limited to 'spec/lib/gitlab/database_spec.rb')
-rw-r--r-- | spec/lib/gitlab/database_spec.rb | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/spec/lib/gitlab/database_spec.rb b/spec/lib/gitlab/database_spec.rb index 60106ee3c0b..5f57cd6b825 100644 --- a/spec/lib/gitlab/database_spec.rb +++ b/spec/lib/gitlab/database_spec.rb @@ -17,6 +17,20 @@ describe Gitlab::Database do end end + describe '.human_adapter_name' do + it 'returns PostgreSQL when using PostgreSQL' do + allow(described_class).to receive(:postgresql?).and_return(true) + + expect(described_class.human_adapter_name).to eq('PostgreSQL') + end + + it 'returns MySQL when using MySQL' do + allow(described_class).to receive(:postgresql?).and_return(false) + + expect(described_class.human_adapter_name).to eq('MySQL') + end + end + # These are just simple smoke tests to check if the methods work (regardless # of what they may return). describe '.mysql?' do @@ -87,6 +101,38 @@ describe Gitlab::Database do end end + describe '.postgresql_minimum_supported_version?' do + it 'returns false when not using PostgreSQL' do + allow(described_class).to receive(:postgresql?).and_return(false) + + expect(described_class.postgresql_minimum_supported_version?).to eq(false) + end + + context 'when using PostgreSQL' do + before do + allow(described_class).to receive(:postgresql?).and_return(true) + end + + it 'returns false when using PostgreSQL 9.5' do + allow(described_class).to receive(:version).and_return('9.5') + + expect(described_class.postgresql_minimum_supported_version?).to eq(false) + end + + it 'returns true when using PostgreSQL 9.6' do + allow(described_class).to receive(:version).and_return('9.6') + + expect(described_class.postgresql_minimum_supported_version?).to eq(true) + end + + it 'returns true when using PostgreSQL 10 or newer' do + allow(described_class).to receive(:version).and_return('10') + + expect(described_class.postgresql_minimum_supported_version?).to eq(true) + end + end + end + describe '.join_lateral_supported?' do it 'returns false when using MySQL' do allow(described_class).to receive(:postgresql?).and_return(false) @@ -195,6 +241,12 @@ describe Gitlab::Database do end end + describe '.pg_last_xact_replay_timestamp' do + it 'returns pg_last_xact_replay_timestamp' do + expect(described_class.pg_last_xact_replay_timestamp).to eq('pg_last_xact_replay_timestamp') + end + end + describe '.nulls_last_order' do context 'when using PostgreSQL' do before do |