newer pg module
[mirror/dsa-puppet.git] / 3rdparty / modules / postgresql / spec / unit / defines / server / reassign_owned_by_spec.rb
1 require 'spec_helper'
2
3 describe 'postgresql::server::reassign_owned_by', :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('reassign_owned_by'),
11       :id => 'root',
12       :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
13     }
14   end
15
16   let :title do
17     'test'
18   end
19
20   let :params do
21     {
22       :db => 'test',
23       :old_role => 'test_old_role',
24       :new_role => 'test_new_role',
25     }
26   end
27
28   let :pre_condition do
29     <<-EOS
30       class {'postgresql::server':}
31       postgresql::server::role{ ['test_old_role','test_new_role']: }
32     EOS
33   end
34
35   it { is_expected.to contain_postgresql__server__reassign_owned_by('test') }
36
37   it {
38     is_expected.to contain_postgresql_psql('reassign_owned_by:test:REASSIGN OWNED BY "test_old_role" TO "test_new_role"').with({
39       'command' => "REASSIGN OWNED BY \"test_old_role\" TO \"test_new_role\"",
40       'onlyif'  => /SELECT tablename FROM pg_catalog.pg_tables WHERE\s*schemaname NOT IN \('pg_catalog', 'information_schema'\) AND\s*tableowner = 'test_old_role'.*/m,
41     }).that_requires('Class[postgresql::server]')
42   }
43
44 end