newer pg module
[mirror/dsa-puppet.git] / 3rdparty / modules / postgresql / spec / acceptance / server / recovery_spec.rb
1 require 'spec_helper_acceptance'
2
3 describe 'postgresql::server::recovery', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
4   describe 'should manage recovery' do
5     after(:all) do
6       pp = <<-EOS.unindent
7         file { '/tmp/recovery.conf':
8           ensure => absent,
9         }
10       EOS
11
12       apply_manifest(pp, :catch_failures => true)
13     end
14
15     it 'adds conf file' do
16       pp = <<-EOS.unindent
17         class { 'postgresql::globals':
18           recovery_conf_path => '/tmp/recovery.conf',
19           manage_recovery_conf => true,
20         }
21
22         class { 'postgresql::server': }
23
24         # Create a recovery.conf file
25         postgresql::server::recovery { "recovery.conf":
26           restore_command          => 'restore_command',
27           recovery_target_timeline => 'recovery_target_timeline',
28         }
29       EOS
30
31       apply_manifest(pp, :catch_failures => true)
32       apply_manifest(pp, :catch_changes => true)
33     end
34
35     describe file('/tmp/recovery.conf') do
36       it { is_expected.to be_file }
37       it { is_expected.to contain /restore_command = 'restore_command'/ }
38       it { is_expected.to contain /recovery_target_timeline = 'recovery_target_timeline'/ }
39     end
40   end
41
42   describe 'should not manage recovery' do
43     it 'does not add conf file' do
44       pp = <<-EOS.unindent
45         class { 'postgresql::globals':
46           manage_recovery_conf => false,
47         }
48
49         class { 'postgresql::server': }
50       EOS
51
52       apply_manifest(pp, :catch_failures => true)
53       apply_manifest(pp, :catch_changes => true)
54     end
55
56     describe file('/tmp/recovery.conf') do
57       it { is_expected.not_to be_file }
58     end
59   end
60 end
61