module-postgresql/spec/unit/classes/server_spec.rb
Ashley Penney 0ee1b9a2ea Convert specs to RSpec 2.99.1 syntax with Transpec
This conversion is done by Transpec 2.3.1 with the following command:
    transpec -f -c "bundle exec rake spec"

* 82 conversions
    from: it { should ... }
      to: it { is_expected.to ... }

* 21 conversions
    from: == expected
      to: eq(expected)

* 20 conversions
    from: obj.should
      to: expect(obj).to

* 5 conversions
    from: its([:key]) { }
      to: describe '[:key]' do subject { super()[:key] }; it { } end

* 1 conversion
    from: it { should_not ... }
      to: it { is_expected.not_to ... }

* 1 conversion
    from: its(:attr) { }
      to: describe '#attr' do subject { super().attr }; it { } end

For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-07-09 16:39:04 -04:00

120 lines
3 KiB
Ruby

require 'spec_helper'
describe 'postgresql::server', :type => :class do
let :facts do
{
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => '6.0',
:concat_basedir => tmpfilename('server'),
:kernel => 'Linux',
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
}
end
describe 'with no parameters' do
it { is_expected.to contain_class("postgresql::params") }
it { is_expected.to contain_class("postgresql::server") }
it 'should validate connection' do
is_expected.to contain_postgresql__validate_db_connection('validate_service_is_running')
end
end
describe 'service_ensure => running' do
let(:params) {{ :service_ensure => 'running' }}
it { is_expected.to contain_class("postgresql::params") }
it { is_expected.to contain_class("postgresql::server") }
it 'should validate connection' do
is_expected.to contain_postgresql__validate_db_connection('validate_service_is_running')
end
end
describe 'service_ensure => stopped' do
let(:params) {{ :service_ensure => 'stopped' }}
it { is_expected.to contain_class("postgresql::params") }
it { is_expected.to contain_class("postgresql::server") }
it 'shouldnt validate connection' do
is_expected.not_to contain_postgresql__validate_db_connection('validate_service_is_running')
end
end
describe 'manage_firewall => true' do
let(:params) do
{
:manage_firewall => true,
:ensure => true,
}
end
it 'should create firewall rule' do
is_expected.to contain_firewall("5432 accept - postgres")
end
end
describe 'ensure => absent' do
let(:params) do
{
:ensure => 'absent',
:datadir => '/my/path',
:xlogdir => '/xlog/path',
}
end
it 'should make package purged' do
is_expected.to contain_package('postgresql-server').with({
:ensure => 'purged',
})
end
it 'stop the service' do
is_expected.to contain_service('postgresqld').with({
:ensure => 'stopped',
})
end
it 'should remove datadir' do
is_expected.to contain_file('/my/path').with({
:ensure => 'absent',
})
end
it 'should remove xlogdir' do
is_expected.to contain_file('/xlog/path').with({
:ensure => 'absent',
})
end
end
describe 'package_ensure => absent' do
let(:params) do
{
:package_ensure => 'absent',
}
end
it 'should remove the package' do
is_expected.to contain_package('postgresql-server').with({
:ensure => 'purged',
})
end
it 'should still enable the service' do
is_expected.to contain_service('postgresqld').with({
:ensure => 'running',
})
end
end
describe 'needs_initdb => true' do
let(:params) do
{
:needs_initdb => true,
}
end
it 'should contain proper initdb exec' do
is_expected.to contain_exec('postgresql_initdb')
end
end
end