3 describe 'postgresql::server::database', :type => :define do
7 :operatingsystem => 'Debian',
8 :operatingsystemrelease => '6.0',
10 :concat_basedir => tmpfilename('contrib'),
12 :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
20 "class {'postgresql::server':}"
23 it { is_expected.to contain_postgresql__server__database('test') }
24 it { is_expected.to contain_postgresql_psql('CREATE DATABASE "test"') }
26 context "with comment set to 'test comment'" do
27 let (:params) {{ :comment => 'test comment' }}
29 it { is_expected.to contain_postgresql_psql("COMMENT ON DATABASE \"test\" IS 'test comment'").with_connect_settings( {} ) }
32 context "with specific db connection settings - default port" do
34 "class {'postgresql::server':}"
37 let (:params) {{ :connect_settings => { 'PGHOST' => 'postgres-db-server',
38 'DBVERSION' => '9.1', }}}
40 it { is_expected.to contain_postgresql_psql('CREATE DATABASE "test"').with_connect_settings( { 'PGHOST' => 'postgres-db-server','DBVERSION' => '9.1' } ).with_port( 5432 ) }
43 context "with specific db connection settings - including port" do
45 "class {'postgresql::globals':}
47 class {'postgresql::server':}"
50 let (:params) {{ :connect_settings => { 'PGHOST' => 'postgres-db-server',
52 'PGPORT' => '1234' }}}
54 it { is_expected.to contain_postgresql_psql('CREATE DATABASE "test"').with_connect_settings( { 'PGHOST' => 'postgres-db-server','DBVERSION' => '9.1','PGPORT' => '1234' } ).with_port( nil ) }
58 context "with global db connection settings - including port" do
60 "class {'postgresql::globals':
61 default_connect_settings => { 'PGHOST' => 'postgres-db-server',
66 class {'postgresql::server':}"
69 it { is_expected.to contain_postgresql_psql('CREATE DATABASE "test"').with_connect_settings( { 'PGHOST' => 'postgres-db-server','DBVERSION' => '9.2','PGPORT' => '1234' } ).with_port( nil ) }
73 context "with different owner" do
74 let (:params) {{ :owner => 'test_owner' }}
76 it { is_expected.to contain_postgresql_psql('ALTER DATABASE "test" OWNER TO "test_owner"') }