2013-02-03 18:25:53 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'postgresql::server', :type => :class do
|
|
|
|
let :facts do
|
|
|
|
{
|
|
|
|
:osfamily => 'Debian',
|
2013-08-27 22:43:47 +02:00
|
|
|
:operatingsystem => 'Debian',
|
|
|
|
:operatingsystemrelease => '6.0',
|
2013-02-10 01:36:12 +01:00
|
|
|
:concat_basedir => tmpfilename('server'),
|
2013-08-27 22:43:47 +02:00
|
|
|
:kernel => 'Linux',
|
2014-04-08 16:40:49 +02:00
|
|
|
:id => 'root',
|
|
|
|
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
|
2013-02-03 18:25:53 +01:00
|
|
|
}
|
|
|
|
end
|
2013-08-27 22:43:47 +02:00
|
|
|
|
|
|
|
describe 'with no parameters' do
|
2014-07-09 18:04:43 +02:00
|
|
|
it { is_expected.to contain_class("postgresql::params") }
|
|
|
|
it { is_expected.to contain_class("postgresql::server") }
|
2013-10-23 23:49:16 +02:00
|
|
|
it 'should validate connection' do
|
2014-07-09 18:04:43 +02:00
|
|
|
is_expected.to contain_postgresql__validate_db_connection('validate_service_is_running')
|
2013-10-23 23:49:16 +02:00
|
|
|
end
|
2013-08-27 22:43:47 +02:00
|
|
|
end
|
|
|
|
|
2014-05-12 23:21:21 +02:00
|
|
|
describe 'service_ensure => running' do
|
|
|
|
let(:params) {{ :service_ensure => 'running' }}
|
2014-07-09 18:04:43 +02:00
|
|
|
it { is_expected.to contain_class("postgresql::params") }
|
|
|
|
it { is_expected.to contain_class("postgresql::server") }
|
2014-05-12 23:21:21 +02:00
|
|
|
it 'should validate connection' do
|
2014-07-09 18:04:43 +02:00
|
|
|
is_expected.to contain_postgresql__validate_db_connection('validate_service_is_running')
|
2014-05-12 23:21:21 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'service_ensure => stopped' do
|
|
|
|
let(:params) {{ :service_ensure => 'stopped' }}
|
2014-07-09 18:04:43 +02:00
|
|
|
it { is_expected.to contain_class("postgresql::params") }
|
|
|
|
it { is_expected.to contain_class("postgresql::server") }
|
2014-05-12 23:21:21 +02:00
|
|
|
it 'shouldnt validate connection' do
|
2014-07-09 18:04:43 +02:00
|
|
|
is_expected.not_to contain_postgresql__validate_db_connection('validate_service_is_running')
|
2014-05-12 23:21:21 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-08-27 22:43:47 +02:00
|
|
|
describe 'package_ensure => absent' do
|
|
|
|
let(:params) do
|
|
|
|
{
|
|
|
|
:package_ensure => 'absent',
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should remove the package' do
|
2014-07-09 18:04:43 +02:00
|
|
|
is_expected.to contain_package('postgresql-server').with({
|
2013-09-14 07:37:22 +02:00
|
|
|
:ensure => 'purged',
|
2013-08-27 22:43:47 +02:00
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should still enable the service' do
|
2014-07-09 18:04:43 +02:00
|
|
|
is_expected.to contain_service('postgresqld').with({
|
2014-05-12 23:34:25 +02:00
|
|
|
:ensure => 'running',
|
2013-08-27 22:43:47 +02:00
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'needs_initdb => true' do
|
|
|
|
let(:params) do
|
|
|
|
{
|
|
|
|
:needs_initdb => true,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should contain proper initdb exec' do
|
2014-07-09 18:04:43 +02:00
|
|
|
is_expected.to contain_exec('postgresql_initdb')
|
2013-08-27 22:43:47 +02:00
|
|
|
end
|
|
|
|
end
|
2013-02-03 18:25:53 +01:00
|
|
|
end
|