newer pg module
[mirror/dsa-puppet.git] / 3rdparty / modules / postgresql / spec / unit / defines / server / pg_ident_rule_spec.rb
1 require 'spec_helper'
2
3 describe 'postgresql::server::pg_ident_rule', :type => :define do
4   let :facts do
5     {
6       :osfamily => 'Debian',
7       :operatingsystem => 'Debian',
8       :operatingsystemrelease => '6.0',
9       :kernel => 'Linux',
10       :concat_basedir => tmpfilename('pg_ident'),
11       :id => 'root',
12       :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
13     }
14   end
15   let :title do
16     'test'
17   end
18   let :target do
19     tmpfilename('pg_ident_rule')
20   end
21
22   context 'managing pg_ident' do
23     let :pre_condition do
24       <<-EOS
25         class { 'postgresql::globals':
26           manage_pg_ident_conf => true,
27         }
28         class { 'postgresql::server': }
29       EOS
30     end
31
32     let :params do
33       {
34         :map_name => 'thatsmymap',
35         :system_username => 'systemuser',
36         :database_username => 'dbuser',
37       }
38     end
39     it do
40       is_expected.to contain_concat__fragment('pg_ident_rule_test').with({
41         :content => /thatsmymap\s+systemuser\s+dbuser/
42       })
43     end
44   end
45   context 'not managing pg_ident' do
46     let :pre_condition do
47       <<-EOS
48         class { 'postgresql::globals':
49           manage_pg_ident_conf => false,
50         }
51         class { 'postgresql::server': }
52       EOS
53     end
54     let :params do
55       {
56           :map_name => 'thatsmymap',
57           :system_username => 'systemuser',
58           :database_username => 'dbuser',
59       }
60     end
61     it 'should fail because $manage_pg_ident_conf is false' do
62       expect { catalogue }.to raise_error(Puppet::Error,
63                                       /postgresql::server::manage_pg_ident_conf has been disabled/)
64     end
65   end
66 end