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',
|
2013-02-03 18:25:53 +01:00
|
|
|
}
|
|
|
|
end
|
2013-08-27 22:43:47 +02:00
|
|
|
|
|
|
|
describe 'with no parameters' do
|
|
|
|
it { should include_class("postgresql::params") }
|
|
|
|
it { should include_class("postgresql::server") }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'manage_firewall => true' do
|
|
|
|
let(:params) do
|
|
|
|
{
|
|
|
|
:manage_firewall => true,
|
|
|
|
:ensure => true,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should create firewall rule' do
|
|
|
|
should contain_firewall("5432 accept - postgres")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'ensure => absent' do
|
|
|
|
let(:params) do
|
|
|
|
{
|
|
|
|
:ensure => 'absent',
|
|
|
|
:datadir => '/my/path',
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should make package absent' do
|
|
|
|
should contain_package('postgresql-server').with({
|
|
|
|
:ensure => 'absent',
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'stop the service' do
|
|
|
|
should contain_service('postgresqld').with({
|
|
|
|
:ensure => false,
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should remove datadir' do
|
|
|
|
should contain_file('/my/path').with({
|
|
|
|
:ensure => 'absent',
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'package_ensure => absent' do
|
|
|
|
let(:params) do
|
|
|
|
{
|
|
|
|
:package_ensure => 'absent',
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should remove the package' do
|
|
|
|
should contain_package('postgresql-server').with({
|
|
|
|
:ensure => 'absent',
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should still enable the service' do
|
|
|
|
should contain_service('postgresqld').with({
|
|
|
|
:ensure => true,
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'needs_initdb => true' do
|
|
|
|
let(:params) do
|
|
|
|
{
|
|
|
|
:needs_initdb => true,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should contain proper initdb exec' do
|
|
|
|
should contain_exec('postgresql_initdb')
|
|
|
|
end
|
|
|
|
end
|
2013-02-03 18:25:53 +01:00
|
|
|
end
|