Merge pull request #402 from mcanevet/fix/strict_variables

Add strict_variables support in unit tests
This commit is contained in:
Ashley Penney 2014-04-09 12:04:32 -04:00
commit 593ed5b9dd
21 changed files with 127 additions and 2 deletions

View file

@ -11,6 +11,7 @@ env:
- PUPPET_GEM_VERSION="~> 2.7.0"
- PUPPET_GEM_VERSION="~> 3.2.0"
- PUPPET_GEM_VERSION="~> 3.4.0"
- PUPPET_GEM_VERSION="~> 3.5.0.rc3" STRICT_VARIABLES="yes"
matrix:
fast_finish: true
exclude:

View file

@ -10,6 +10,7 @@ class postgresql::globals (
$java_package_name = undef,
$plperl_package_name = undef,
$python_package_name = undef,
$postgis_package_name = undef,
$service_name = undef,
$service_provider = undef,

View file

@ -21,6 +21,8 @@ class postgresql::params inherits postgresql::globals {
$group = pick($group, 'postgres')
$needs_initdb = pick($needs_initdb, true)
$firewall_supported = pick($firewall_supported, true)
$version_parts = split($version, '[.]')
$package_version = "${version_parts[0]}${version_parts[1]}"
if $version == $default_version {
$client_package_name = pick($client_package_name, 'postgresql')
@ -37,8 +39,6 @@ class postgresql::params inherits postgresql::globals {
}
$confdir = pick($confdir, $datadir)
} else {
$version_parts = split($version, '[.]')
$package_version = "${version_parts[0]}${version_parts[1]}"
$client_package_name = pick($client_package_name, "postgresql${package_version}")
$server_package_name = pick($server_package_name, "postgresql${package_version}-server")
$contrib_package_name = pick($contrib_package_name,"postgresql${package_version}-contrib")

View file

@ -1,5 +1,6 @@
# PRIVATE CLASS: do not use directly
class postgresql::repo::apt_postgresql_org inherits postgresql::repo {
include ::apt
if($ensure == 'present' or $ensure == true) {
# Here we have tried to replicate the instructions on the PostgreSQL site:
#

View file

@ -16,6 +16,10 @@ RSpec.configure do |c|
# Store any environment variables away to be restored later
@old_env = {}
ENV.each_key {|k| @old_env[k] = ENV[k]}
if ENV['STRICT_VARIABLES'] == 'yes'
Puppet.settings[:strict_variables]=true
end
end
c.after :each do

View file

@ -7,6 +7,7 @@ describe 'postgresql::globals', :type => :class do
:operatingsystem => 'Debian',
:operatingsystemrelease => '6.0',
:lsbdistid => 'Debian',
:lsbdistcodename => 'squeeze',
}
end

View file

@ -7,6 +7,7 @@ describe 'postgresql::repo', :type => :class do
:operatingsystem => 'Debian',
:operatingsystemrelease => '6.0',
:lsbdistid => 'Debian',
:lsbdistcodename => 'squeeze',
}
end

View file

@ -12,6 +12,8 @@ describe 'postgresql::server::contrib', :type => :class do
:operatingsystemrelease => '6.0',
:kernel => 'Linux',
:concat_basedir => tmpfilename('contrib'),
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
}
end

View file

@ -11,6 +11,9 @@ describe 'postgresql::server::initdb', :type => :class do
:operatingsystem => 'CentOS',
: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
it { should contain_file('/var/lib/pgsql/data').with_ensure('directory') }
@ -21,6 +24,9 @@ describe 'postgresql::server::initdb', :type => :class do
:osfamily => 'RedHat',
:operatingsystem => 'Amazon',
:concat_basedir => tmpfilename('server'),
:kernel => 'Linux',
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
}
end
it { should contain_file('/var/lib/pgsql9/data').with_ensure('directory') }

View file

@ -8,6 +8,8 @@ describe 'postgresql::server::plperl', :type => :class do
:operatingsystemrelease => '6.0',
:kernel => 'Linux',
:concat_basedir => tmpfilename('plperl'),
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
}
end

View file

@ -12,6 +12,8 @@ describe 'postgresql::server::postgis', :type => :class do
:operatingsystemrelease => '6.0',
:kernel => 'Linux',
:concat_basedir => tmpfilename('postgis'),
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
}
end

View file

@ -8,6 +8,8 @@ describe 'postgresql::server', :type => :class do
: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

View file

@ -6,6 +6,10 @@ describe 'postgresql::server::config_entry', :type => :define do
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemrelease => '6.4',
:kernel => 'Linux',
:concat_basedir => tmpfilename('contrib'),
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
}
end
@ -16,6 +20,10 @@ describe 'postgresql::server::config_entry', :type => :define do
end
context "syntax check" do
let :pre_condition do
"class {'postgresql::server':}"
end
let(:params) { { :ensure => 'present'} }
it { should contain_postgresql__server__config_entry('config_entry') }
end

View file

@ -6,6 +6,10 @@ describe 'postgresql::server::database_grant', :type => :define do
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => '6.0',
:kernel => 'Linux',
:concat_basedir => tmpfilename('contrib'),
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
}
end
@ -21,6 +25,10 @@ describe 'postgresql::server::database_grant', :type => :define do
}
end
let :pre_condition do
"class {'postgresql::server':}"
end
it { should contain_postgresql__server__database_grant('test') }
it { should contain_postgresql__server__grant('database:test') }
end

View file

@ -6,11 +6,20 @@ describe 'postgresql::server::database', :type => :define do
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => '6.0',
:kernel => 'Linux',
:concat_basedir => tmpfilename('contrib'),
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
}
end
let :title do
'test'
end
let :pre_condition do
"class {'postgresql::server':}"
end
it { should contain_postgresql__server__database('test') }
it { should contain_postgresql_psql("Check for existence of db 'test'") }
end

View file

@ -6,6 +6,10 @@ describe 'postgresql::server::db', :type => :define do
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => '6.0',
:kernel => 'Linux',
:concat_basedir => tmpfilename('contrib'),
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
}
end
@ -23,6 +27,10 @@ describe 'postgresql::server::db', :type => :define do
}
end
let :pre_condition do
"class {'postgresql::server':}"
end
it { should contain_postgresql__server__db('test') }
it { should contain_postgresql__server__database('test').with_owner('tester') }
it { should contain_postgresql__server__role('test') }
@ -41,6 +49,10 @@ describe 'postgresql::server::db', :type => :define do
}
end
let :pre_condition do
"class {'postgresql::server':}"
end
it { should contain_postgresql__server__database('testtest') }
end
end

View file

@ -6,6 +6,10 @@ describe 'postgresql::server::grant', :type => :define do
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => '6.0',
:kernel => 'Linux',
:concat_basedir => tmpfilename('contrib'),
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
}
end
@ -20,5 +24,9 @@ describe 'postgresql::server::grant', :type => :define do
}
end
let :pre_condition do
"class {'postgresql::server':}"
end
it { should contain_postgresql__server__grant('test') }
end

View file

@ -6,7 +6,10 @@ describe 'postgresql::server::pg_hba_rule', :type => :define do
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => '6.0',
:kernel => 'Linux',
:concat_basedir => tmpfilename('pg_hba'),
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
}
end
let :title do
@ -17,6 +20,12 @@ describe 'postgresql::server::pg_hba_rule', :type => :define do
end
context 'test template 1' do
let :pre_condition do
<<-EOS
class { 'postgresql::server': }
EOS
end
let :params do
{
:type => 'host',
@ -35,6 +44,12 @@ describe 'postgresql::server::pg_hba_rule', :type => :define do
end
context 'test template 2' do
let :pre_condition do
<<-EOS
class { 'postgresql::server': }
EOS
end
let :params do
{
:type => 'local',
@ -52,6 +67,12 @@ describe 'postgresql::server::pg_hba_rule', :type => :define do
end
context 'test template 3' do
let :pre_condition do
<<-EOS
class { 'postgresql::server': }
EOS
end
let :params do
{
:type => 'host',
@ -72,6 +93,12 @@ describe 'postgresql::server::pg_hba_rule', :type => :define do
context 'validation' do
context 'validate type test 1' do
let :pre_condition do
<<-EOS
class { 'postgresql::server': }
EOS
end
let :params do
{
:type => 'invalid',
@ -89,6 +116,12 @@ describe 'postgresql::server::pg_hba_rule', :type => :define do
end
context 'validate auth_method' do
let :pre_condition do
<<-EOS
class { 'postgresql::server': }
EOS
end
let :params do
{
:type => 'local',

View file

@ -6,6 +6,10 @@ describe 'postgresql::server::role', :type => :define do
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => '6.0',
:kernel => 'Linux',
:concat_basedir => tmpfilename('contrib'),
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
}
end
@ -19,5 +23,9 @@ describe 'postgresql::server::role', :type => :define do
}
end
let :pre_condition do
"class {'postgresql::server':}"
end
it { should contain_postgresql__server__role('test') }
end

View file

@ -6,6 +6,10 @@ describe 'postgresql::server::table_grant', :type => :define do
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => '6.0',
:kernel => 'Linux',
:concat_basedir => tmpfilename('table_grant'),
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
}
end
@ -22,6 +26,10 @@ describe 'postgresql::server::table_grant', :type => :define do
}
end
let :pre_condition do
"class {'postgresql::server':}"
end
it { should contain_postgresql__server__table_grant('test') }
it { should contain_postgresql__server__grant('table:test') }
end

View file

@ -6,6 +6,10 @@ describe 'postgresql::server::tablespace', :type => :define do
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => '6.0',
:kernel => 'Linux',
:concat_basedir => tmpfilename('tablespace'),
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
}
end
@ -19,5 +23,9 @@ describe 'postgresql::server::tablespace', :type => :define do
}
end
let :pre_condition do
"class {'postgresql::server':}"
end
it { should contain_postgresql__server__tablespace('test') }
end