forked from puppetlabs/puppetlabs-postgresql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathz_alternative_pgdata_spec.rb
33 lines (27 loc) · 1.04 KB
/
z_alternative_pgdata_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
require 'spec_helper_acceptance'
# These tests ensure that postgres can change itself to an alternative pgdata
# location properly.
# Allow postgresql to use /tmp/* as a datadir
if fact('osfamily') == 'RedHat' && fact('selinux') == 'true'
shell 'setenforce 0'
end
describe 'postgresql::server', unless: UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
it 'on an alternative pgdata location' do
pp = <<-MAIFEST
#file { '/var/lib/pgsql': ensure => directory, } ->
# needs_initdb will be true by default for all OS's except Debian
# in order to change the datadir we need to tell it explicitly to call initdb
class { 'postgresql::server': datadir => '/tmp/data', needs_initdb => true }
MAIFEST
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end
describe file('/tmp/data') do
it { is_expected.to be_directory }
end
it 'can connect with psql' do
psql('--command="\l" postgres', 'postgres') do |r|
expect(r.stdout).to match(%r{List of databases})
end
end
end