3 describe 'postgresql::server::extension', :type => :define do
5 "class { 'postgresql::server': }
6 postgresql::server::database { 'template_postgis':
7 template => 'template1',
13 :osfamily => 'Debian',
14 :operatingsystem => 'Debian',
15 :operatingsystemrelease => '6.0',
17 :concat_basedir => tmpfilename('postgis'),
19 :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
23 let (:title) { 'postgis' }
25 :database => 'template_postgis',
28 context "with mandatory arguments only" do
30 is_expected.to contain_postgresql_psql('Add postgis extension to template_postgis').with({
31 :db => 'template_postgis',
32 :command => 'CREATE EXTENSION "postgis"',
33 :unless => "SELECT t.count FROM (SELECT count(extname) FROM pg_extension WHERE extname = 'postgis') as t WHERE t.count = 1",
34 }).that_requires('Postgresql::Server::Database[template_postgis]')
38 context "when setting package name" do
39 let (:params) { super().merge({
40 :package_name => 'postgis',
44 is_expected.to contain_package('postgis').with({
47 }).that_comes_before('Postgresql_psql[Add postgis extension to template_postgis]')
51 context "when ensuring absence" do
52 let (:params) { super().merge({
54 :package_name => 'postgis',
58 is_expected.to contain_postgresql_psql('Add postgis extension to template_postgis').with({
59 :db => 'template_postgis',
60 :command => 'DROP EXTENSION "postgis"',
61 :unless => "SELECT t.count FROM (SELECT count(extname) FROM pg_extension WHERE extname = 'postgis') as t WHERE t.count != 1",
62 }).that_requires('Postgresql::Server::Database[template_postgis]')
66 is_expected.to contain_package('postgis').with({
72 context "when keeping package installed" do
73 let (:params) { super().merge({
74 :package_ensure => 'present',
78 is_expected.to contain_postgresql_psql('Add postgis extension to template_postgis').with({
79 :db => 'template_postgis',
80 :command => 'DROP EXTENSION "postgis"',
81 :unless => "SELECT t.count FROM (SELECT count(extname) FROM pg_extension WHERE extname = 'postgis') as t WHERE t.count != 1",
82 }).that_requires('Postgresql::Server::Database[template_postgis]')
86 is_expected.to contain_package('postgis').with({
89 }).that_requires('Postgresql_psql[Add postgis extension to template_postgis]')
95 describe 'postgresql::server::extension', :type => :define do
97 "class { 'postgresql::server': }
98 postgresql::server::database { 'template_postgis2':
99 template => 'template1',
105 :osfamily => 'Debian',
106 :operatingsystem => 'Debian',
107 :operatingsystemrelease => '6.0',
109 :concat_basedir => tmpfilename('postgis'),
111 :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
115 let (:title) { 'postgis_db2' }
117 :database => 'template_postgis2',
118 :extension => 'postgis',
121 context "with mandatory arguments only" do
123 is_expected.to contain_postgresql_psql('Add postgis extension to template_postgis2').with({
124 :db => 'template_postgis2',
125 :command => 'CREATE EXTENSION "postgis"',
126 :unless => "SELECT t.count FROM (SELECT count(extname) FROM pg_extension WHERE extname = 'postgis') as t WHERE t.count = 1",
127 }).that_requires('Postgresql::Server::Database[template_postgis2]')