2013-02-03 18:25:53 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'postgresql::validate_db_connection', :type => :define do
|
|
|
|
let :facts do
|
|
|
|
{
|
|
|
|
:osfamily => 'Debian',
|
2013-08-27 22:43:47 +02:00
|
|
|
:operatingsystem => 'Debian',
|
|
|
|
:operatingsystemrelease => '6.0',
|
2013-02-03 18:25:53 +01:00
|
|
|
}
|
|
|
|
end
|
2013-08-27 22:43:47 +02:00
|
|
|
|
2013-02-03 18:25:53 +01:00
|
|
|
let :title do
|
|
|
|
'test'
|
|
|
|
end
|
2013-08-27 22:43:47 +02:00
|
|
|
|
2013-10-23 23:49:16 +02:00
|
|
|
describe 'should work with only default parameters' do
|
2014-07-09 18:04:43 +02:00
|
|
|
it { is_expected.to contain_postgresql__validate_db_connection('test') }
|
2013-10-23 23:49:16 +02:00
|
|
|
end
|
|
|
|
|
2013-08-27 22:43:47 +02:00
|
|
|
describe 'should work with all parameters' do
|
|
|
|
let :params do
|
|
|
|
{
|
|
|
|
:database_host => 'test',
|
|
|
|
:database_name => 'test',
|
|
|
|
:database_password => 'test',
|
|
|
|
:database_username => 'test',
|
|
|
|
:database_port => 5432,
|
2013-10-23 23:49:16 +02:00
|
|
|
:run_as => 'postgresq',
|
|
|
|
:sleep => 4,
|
|
|
|
:tries => 30,
|
2013-08-27 22:43:47 +02:00
|
|
|
}
|
|
|
|
end
|
2014-07-09 18:04:43 +02:00
|
|
|
it { is_expected.to contain_postgresql__validate_db_connection('test') }
|
2014-04-30 14:30:03 +02:00
|
|
|
|
|
|
|
it 'should have proper path for validate command' do
|
|
|
|
is_expected.to contain_exec('validate postgres connection for test@test:5432/test').with({
|
|
|
|
:unless => %r'^/usr/local/bin/validate_postgresql_connection.sh\s+\d+'
|
|
|
|
})
|
|
|
|
end
|
2013-02-03 18:25:53 +01:00
|
|
|
end
|
2014-04-30 14:30:03 +02:00
|
|
|
|
|
|
|
describe 'should work while specifying validate_connection in postgresql::client' do
|
|
|
|
|
|
|
|
let :params do
|
|
|
|
{
|
|
|
|
:database_host => 'test',
|
|
|
|
:database_name => 'test',
|
|
|
|
:database_password => 'test',
|
|
|
|
:database_username => 'test',
|
|
|
|
:database_port => 5432
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
let :pre_condition do
|
|
|
|
"class { 'postgresql::client': validcon_script_path => '/opt/something/validate.sh' }"
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should have proper path for validate command' do
|
|
|
|
is_expected.to contain_exec('validate postgres connection for test@test:5432/test').with({
|
|
|
|
:unless => %r'^/opt/something/validate.sh\s+\d+'
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2013-02-03 18:25:53 +01:00
|
|
|
end
|