diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2018-07-24 13:23:54 +0200 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2018-07-24 13:25:01 +0200 |
commit | 2ade035eb253a5a69f05acab26b3e5ad6d3eb233 (patch) | |
tree | 5cf37782cef62c07d326a76e97e4a6a9dd806c6e /spec | |
parent | 1c24eafb4106dc7890ef74093a59009e94baa705 (diff) | |
download | gitlab-ce-2ade035eb253a5a69f05acab26b3e5ad6d3eb233.tar.gz |
Backport various EE changes to Gitlab::Databasebackport-gitlab-database
These changes are useful for CE as well. For example, the MR
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/20720 can make
use of some of the backported methods.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/database_spec.rb | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/spec/lib/gitlab/database_spec.rb b/spec/lib/gitlab/database_spec.rb index 782e4e45a91..7d76519dddd 100644 --- a/spec/lib/gitlab/database_spec.rb +++ b/spec/lib/gitlab/database_spec.rb @@ -65,6 +65,28 @@ describe Gitlab::Database do end end + describe '.postgresql_9_or_less?' do + it 'returns false when using MySQL' do + allow(described_class).to receive(:postgresql?).and_return(false) + + expect(described_class.postgresql_9_or_less?).to eq(false) + end + + it 'returns true when using PostgreSQL 9.6' do + allow(described_class).to receive(:postgresql?).and_return(true) + allow(described_class).to receive(:version).and_return('9.6') + + expect(described_class.postgresql_9_or_less?).to eq(true) + end + + it 'returns false when using PostgreSQL 10 or newer' do + allow(described_class).to receive(:postgresql?).and_return(true) + allow(described_class).to receive(:version).and_return('10') + + expect(described_class.postgresql_9_or_less?).to eq(false) + end + end + describe '.join_lateral_supported?' do it 'returns false when using MySQL' do allow(described_class).to receive(:postgresql?).and_return(false) @@ -109,6 +131,70 @@ describe Gitlab::Database do end end + describe '.pg_wal_lsn_diff' do + it 'returns old name when using PostgreSQL 9.6' do + allow(described_class).to receive(:postgresql?).and_return(true) + allow(described_class).to receive(:version).and_return('9.6') + + expect(described_class.pg_wal_lsn_diff).to eq('pg_xlog_location_diff') + end + + it 'returns new name when using PostgreSQL 10 or newer' do + allow(described_class).to receive(:postgresql?).and_return(true) + allow(described_class).to receive(:version).and_return('10') + + expect(described_class.pg_wal_lsn_diff).to eq('pg_wal_lsn_diff') + end + end + + describe '.pg_current_wal_insert_lsn' do + it 'returns old name when using PostgreSQL 9.6' do + allow(described_class).to receive(:postgresql?).and_return(true) + allow(described_class).to receive(:version).and_return('9.6') + + expect(described_class.pg_current_wal_insert_lsn).to eq('pg_current_xlog_insert_location') + end + + it 'returns new name when using PostgreSQL 10 or newer' do + allow(described_class).to receive(:postgresql?).and_return(true) + allow(described_class).to receive(:version).and_return('10') + + expect(described_class.pg_current_wal_insert_lsn).to eq('pg_current_wal_insert_lsn') + end + end + + describe '.pg_last_wal_receive_lsn' do + it 'returns old name when using PostgreSQL 9.6' do + allow(described_class).to receive(:postgresql?).and_return(true) + allow(described_class).to receive(:version).and_return('9.6') + + expect(described_class.pg_last_wal_receive_lsn).to eq('pg_last_xlog_receive_location') + end + + it 'returns new name when using PostgreSQL 10 or newer' do + allow(described_class).to receive(:postgresql?).and_return(true) + allow(described_class).to receive(:version).and_return('10') + + expect(described_class.pg_last_wal_receive_lsn).to eq('pg_last_wal_receive_lsn') + end + end + + describe '.pg_last_wal_replay_lsn' do + it 'returns old name when using PostgreSQL 9.6' do + allow(described_class).to receive(:postgresql?).and_return(true) + allow(described_class).to receive(:version).and_return('9.6') + + expect(described_class.pg_last_wal_replay_lsn).to eq('pg_last_xlog_replay_location') + end + + it 'returns new name when using PostgreSQL 10 or newer' do + allow(described_class).to receive(:postgresql?).and_return(true) + allow(described_class).to receive(:version).and_return('10') + + expect(described_class.pg_last_wal_replay_lsn).to eq('pg_last_wal_replay_lsn') + end + end + describe '.nulls_last_order' do context 'when using PostgreSQL' do before do |