newer pg module
[mirror/dsa-puppet.git] / 3rdparty / modules / postgresql / spec / unit / classes / lib / devel_spec.rb
1 require 'spec_helper'
2
3 describe 'postgresql::lib::devel', :type => :class do
4   let :facts do
5     {
6       :osfamily => 'Debian',
7       :operatingsystem => 'Debian',
8       :operatingsystemrelease => '6.0',
9     }
10   end
11   it { is_expected.to contain_class("postgresql::lib::devel") }
12
13   describe 'link pg_config to /usr/bin' do
14     it { should_not contain_file('/usr/bin/pg_config') \
15       .with_ensure('link') \
16       .with_target('/usr/lib/postgresql/8.4/bin/pg_config')
17     }
18   end
19
20   describe 'disable link_pg_config' do
21     let(:params) {{
22       :link_pg_config => false,
23     }}
24     it { should_not contain_file('/usr/bin/pg_config') }
25   end
26
27   describe 'should not link pg_config on RedHat with default version' do
28     let(:facts) {{
29       :osfamily                  => 'RedHat',
30       :operatingsystem           => 'CentOS',
31       :operatingsystemrelease    => '6.3',
32       :operatingsystemmajrelease => '6',
33     }}
34     it { should_not contain_file('/usr/bin/pg_config') }
35   end
36
37   describe 'link pg_config on RedHat with non-default version' do
38     let(:facts) {{
39       :osfamily                  => 'RedHat',
40       :operatingsystem           => 'CentOS',
41       :operatingsystemrelease    => '6.3',
42       :operatingsystemmajrelease => '6',
43     }}
44     let :pre_condition do
45     "class { '::postgresql::globals': version => '9.3' }"
46     end
47
48     it { should contain_file('/usr/bin/pg_config') \
49       .with_ensure('link') \
50       .with_target('/usr/pgsql-9.3/bin/pg_config')
51     }
52   end
53
54   describe 'on Gentoo' do
55     let :facts do
56       {
57         :osfamily => 'Gentoo',
58         :operatingsystem => 'Gentoo',
59       }
60     end
61     let :params do
62       {
63         :link_pg_config => false,
64       }
65     end
66
67     it 'should fail to compile' do
68       expect {
69         is_expected.to compile
70       }.to raise_error(/is not supported/)
71     end
72   end
73 end