2014-01-22 01:45:58 +01:00
|
|
|
require 'spec_helper_acceptance'
|
2013-08-27 22:43:47 +02:00
|
|
|
|
2014-02-27 20:29:59 +01:00
|
|
|
describe 'postgresql_psql:', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
|
2013-08-27 22:43:47 +02:00
|
|
|
after :all do
|
|
|
|
# Cleanup after tests have ran
|
2014-01-22 01:45:58 +01:00
|
|
|
apply_manifest("class { 'postgresql::server': ensure => absent }", :catch_failures => true)
|
2013-08-27 22:43:47 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should run some SQL when the unless query returns no rows' do
|
2013-09-18 23:25:51 +02:00
|
|
|
pp = <<-EOS.unindent
|
2013-08-27 22:43:47 +02:00
|
|
|
class { 'postgresql::server': }
|
|
|
|
|
|
|
|
postgresql_psql { 'foobar':
|
|
|
|
db => 'postgres',
|
|
|
|
psql_user => 'postgres',
|
|
|
|
command => 'select 1',
|
|
|
|
unless => 'select 1 where 1=2',
|
|
|
|
require => Class['postgresql::server'],
|
|
|
|
}
|
|
|
|
EOS
|
|
|
|
|
2014-01-22 01:45:58 +01:00
|
|
|
apply_manifest(pp, :catch_failures => true)
|
|
|
|
apply_manifest(pp, :catch_failures => true)
|
2013-08-27 22:43:47 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should not run SQL when the unless query returns rows' do
|
2013-09-18 23:25:51 +02:00
|
|
|
pp = <<-EOS.unindent
|
2013-08-27 22:43:47 +02:00
|
|
|
class { 'postgresql::server': }
|
|
|
|
|
|
|
|
postgresql_psql { 'foobar':
|
|
|
|
db => 'postgres',
|
|
|
|
psql_user => 'postgres',
|
|
|
|
command => 'select * from pg_database limit 1',
|
|
|
|
unless => 'select 1 where 1=1',
|
|
|
|
require => Class['postgresql::server'],
|
|
|
|
}
|
|
|
|
EOS
|
|
|
|
|
2014-01-22 01:45:58 +01:00
|
|
|
apply_manifest(pp, :catch_failures => true)
|
|
|
|
apply_manifest(pp, :catch_changes => true)
|
2013-08-27 22:43:47 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|