Rename pg_stat_wal_receiver_supported? DB helper
From pg_stat_wal_receiver_supported? to postgresql_minimum_supported_version? Also add test coverage
This commit is contained in:
parent
80eaed2aeb
commit
26134eeece
2 changed files with 43 additions and 1 deletions
|
@ -76,7 +76,7 @@ module Gitlab
|
|||
postgresql? && version.to_f >= 9.4
|
||||
end
|
||||
|
||||
def self.pg_stat_wal_receiver_supported?
|
||||
def self.postgresql_minimum_supported_version?
|
||||
postgresql? && version.to_f >= 9.6
|
||||
end
|
||||
|
||||
|
@ -98,6 +98,10 @@ module Gitlab
|
|||
Gitlab::Database.postgresql_9_or_less? ? 'pg_last_xlog_replay_location' : 'pg_last_wal_replay_lsn'
|
||||
end
|
||||
|
||||
def self.pg_last_xact_replay_timestamp
|
||||
'pg_last_xact_replay_timestamp'
|
||||
end
|
||||
|
||||
def self.nulls_last_order(field, direction = 'ASC')
|
||||
order = "#{field} #{direction}"
|
||||
|
||||
|
|
|
@ -87,6 +87,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 +227,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
|
||||
|
|
Loading…
Reference in a new issue