newer pg module
[mirror/dsa-puppet.git] / 3rdparty / modules / postgresql / spec / acceptance / z_alternative_pgdata_spec.rb
1 require 'spec_helper_acceptance'
2
3 # These tests ensure that postgres can change itself to an alternative pgdata
4 # location properly.
5
6 # Allow postgresql to use /tmp/* as a datadir
7 if fact('osfamily') == 'RedHat' and fact('selinux') == 'true'
8   shell 'setenforce 0'
9 end
10
11 describe 'postgresql::server', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
12   it 'on an alternative pgdata location' do
13     pp = <<-EOS
14       #file { '/var/lib/pgsql': ensure => directory, } ->
15       # needs_initdb will be true by default for all OS's except Debian
16       # in order to change the datadir we need to tell it explicitly to call initdb
17       class { 'postgresql::server': datadir => '/tmp/data', needs_initdb => true }
18     EOS
19
20     apply_manifest(pp, :catch_failures => true)
21     apply_manifest(pp, :catch_changes => true)
22   end
23
24   describe file('/tmp/data') do
25     it { should be_directory }
26   end
27
28   it 'can connect with psql' do
29     psql('--command="\l" postgres', 'postgres') do |r|
30       expect(r.stdout).to match(/List of databases/)
31     end
32   end
33
34 end