Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up specs #448

Merged
merged 2 commits into from
Nov 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 2 additions & 9 deletions spec/classes/puppet_agent_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,10 @@

describe 'puppet::agent::config' do

on_supported_os.each do |os, facts|
next if only_test_os() and not only_test_os.include?(os)
next if exclude_test_os() and exclude_test_os.include?(os)
on_os_under_test.each do |os, facts|
next if facts[:osfamily] == 'windows' # TODO, see https://github.com/fessyfoo/rspec-puppet-windows-issue
context "on #{os}" do
let(:facts) do
facts.merge({
:concat_basedir => '/foo/bar',
:puppetversion => Puppet.version,
})
end
let(:facts) { facts }

context 'with default parameters' do
let :pre_condition do
Expand Down
22 changes: 7 additions & 15 deletions spec/classes/puppet_agent_install_spec.rb
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
require 'spec_helper'

describe 'puppet::agent::install' do
on_supported_os.each do |os, os_facts|
next if only_test_os() and not only_test_os.include?(os)
next if exclude_test_os() and exclude_test_os.include?(os)
on_os_under_test.each do |os, facts|
context "on #{os}" do
let (:default_facts) do
os_facts.merge({
:concat_basedir => '/nonexistant',
:puppetversion => Puppet.version,
}) end

if Puppet.version < '4.0'
if os_facts[:osfamily] == 'FreeBSD'
if facts[:osfamily] == 'FreeBSD'
client_package = 'puppet38'
else
client_package = 'puppet'
end
additional_facts = {}
else
if os_facts[:osfamily] == 'FreeBSD'
if facts[:osfamily] == 'FreeBSD'
client_package = 'puppet4'
additional_facts = {}
else
client_package = 'puppet-agent'
if os_facts[:osfamily] == 'windows'
if facts[:osfamily] == 'windows'
additional_facts = {}
else
additional_facts = {:rubysitedir => '/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0'}
Expand All @@ -33,15 +25,15 @@
end

let (:facts) do
default_facts.merge(additional_facts)
facts.merge(additional_facts)
end

describe 'with default parameters' do
let :pre_condition do
'include ::puppet'
end

if os_facts[:osfamily] == 'windows'
if facts[:osfamily] == 'windows'
it 'should define provider as chocolatey on Windows' do
should contain_package(client_package).with_provider('chocolatey')
end
Expand Down Expand Up @@ -90,7 +82,7 @@
end
end

if os_facts[:osfamily] == 'windows'
if facts[:osfamily] == 'windows'
describe "when package_provider => 'msi'" do
let :pre_condition do
"class { 'puppet': package_provider => 'msi', }"
Expand Down
18 changes: 4 additions & 14 deletions spec/classes/puppet_agent_service_cron_spec.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
require 'spec_helper'

describe 'puppet::agent::service::cron' do
on_supported_os.each do |os, os_facts|
next if only_test_os() and not only_test_os.include?(os)
next if exclude_test_os() and exclude_test_os.include?(os)
on_os_under_test.each do |os, facts|
context "on #{os}" do
let (:default_facts) do
os_facts.merge({
:clientcert => 'puppetmaster.example.com',
:concat_basedir => '/nonexistant',
:fqdn => 'puppetmaster.example.com',
:puppetversion => Puppet.version,
}) end

if Puppet.version < '4.0'
confdir = '/etc/puppet'
bindir = '/usr/bin'
Expand All @@ -23,13 +13,13 @@
additional_facts = {:rubysitedir => '/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0'}
end

if os_facts[:osfamily] == 'FreeBSD'
if facts[:osfamily] == 'FreeBSD'
bindir = '/usr/local/bin'
confdir = '/usr/local/etc/puppet'
end

let :facts do
default_facts.merge(additional_facts)
facts.merge(additional_facts)
end

describe 'when runmode is not cron' do
Expand All @@ -52,7 +42,7 @@
it do
case os
when /\A(windows|archlinux)/
should raise_error(Puppet::Error, /Runmode of cron not supported on #{os_facts[:kernel]} operating systems!/)
should raise_error(Puppet::Error, /Runmode of cron not supported on #{facts[:kernel]} operating systems!/)
else
should contain_cron('puppet').with({
:command => "#{bindir}/puppet agent --config #{confdir}/puppet.conf --onetime --no-daemonize",
Expand Down
18 changes: 4 additions & 14 deletions spec/classes/puppet_agent_service_daemon_spec.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
require 'spec_helper'

describe 'puppet::agent::service::daemon' do
on_supported_os.each do |os, os_facts|
next if only_test_os() and not only_test_os.include?(os)
next if exclude_test_os() and exclude_test_os.include?(os)
on_os_under_test.each do |os, facts|
context "on #{os}" do
let (:default_facts) do
os_facts.merge({
:clientcert => 'puppetmaster.example.com',
:concat_basedir => '/nonexistant',
:fqdn => 'puppetmaster.example.com',
:puppetversion => Puppet.version,
}) end

if Puppet.version < '4.0'
confdir = '/etc/puppet'
additional_facts = {}
Expand All @@ -21,12 +11,12 @@
additional_facts = {:rubysitedir => '/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0'}
end

if os_facts[:osfamily] == 'FreeBSD'
if facts[:osfamily] == 'FreeBSD'
confdir = '/usr/local/etc/puppet'
end

let :facts do
default_facts.merge(additional_facts)
facts.merge(additional_facts)
end

describe 'when runmode => daemon' do
Expand All @@ -51,7 +41,7 @@
it do
case os
when /\A(windows|archlinux)/
should raise_error(Puppet::Error, /Runmode of cron not supported on #{os_facts[:kernel]} operating systems!/)
should raise_error(Puppet::Error, /Runmode of cron not supported on #{facts[:kernel]} operating systems!/)
else
should contain_service('puppet').with({
:ensure => 'stopped',
Expand Down
20 changes: 5 additions & 15 deletions spec/classes/puppet_agent_service_spec.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
require 'spec_helper'

describe 'puppet::agent::service' do
on_supported_os.each do |os, os_facts|
next if only_test_os() and not only_test_os.include?(os)
next if exclude_test_os() and exclude_test_os.include?(os)
on_os_under_test.each do |os, facts|
context "on #{os}" do
let (:default_facts) do
os_facts.merge({
:clientcert => 'puppetmaster.example.com',
:concat_basedir => '/nonexistant',
:fqdn => 'puppetmaster.example.com',
:puppetversion => Puppet.version,
}) end

if Puppet.version < '4.0'
confdir = '/etc/puppet'
additional_facts = {}
Expand All @@ -21,12 +11,12 @@
additional_facts = {:rubysitedir => '/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0'}
end

if os_facts[:osfamily] == 'FreeBSD'
if facts[:osfamily] == 'FreeBSD'
confdir = '/usr/local/etc/puppet'
end

let :facts do
default_facts.merge(additional_facts)
facts.merge(additional_facts)
end

describe 'with no custom parameters' do
Expand Down Expand Up @@ -59,7 +49,7 @@
case os
when /\A(windows|archlinux)/
it do
should raise_error(Puppet::Error, /Runmode of cron not supported on #{os_facts[:kernel]} operating systems!/)
should raise_error(Puppet::Error, /Runmode of cron not supported on #{facts[:kernel]} operating systems!/)
end
when /\Adebian-8/, /\A(redhat|centos|scientific)-7/, /\Afedora-/, /\Aubuntu-16/
it do
Expand Down Expand Up @@ -91,7 +81,7 @@
should contain_service('puppet-run.timer').with(:ensure => :running)
end
else
it { should raise_error(Puppet::Error, /Runmode of systemd.timer not supported on #{os_facts[:kernel]} operating systems!/) }
it { should raise_error(Puppet::Error, /Runmode of systemd.timer not supported on #{facts[:kernel]} operating systems!/) }
end
end

Expand Down
26 changes: 7 additions & 19 deletions spec/classes/puppet_agent_service_systemd_spec.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
require 'spec_helper'

describe 'puppet::agent::service::systemd' do
on_supported_os.each do |os, os_facts|
next if only_test_os() and not only_test_os.include?(os)
next if exclude_test_os() and exclude_test_os.include?(os)
on_os_under_test.each do |os, facts|
context "on #{os}" do
let (:default_facts) do
os_facts.merge({
:clientcert => 'puppetmaster.example.com',
:concat_basedir => '/nonexistant',
:fqdn => 'puppetmaster.example.com',
:puppetversion => Puppet.version,
}) end

if Puppet.version < '4.0'
confdir = '/etc/puppet'
additional_facts = {}
Expand All @@ -21,16 +11,14 @@
additional_facts = {:rubysitedir => '/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0'}
end

if os_facts[:osfamily] == 'FreeBSD'
if facts[:osfamily] == 'FreeBSD'
confdir = '/usr/local/etc/puppet'
end

if os_facts[:osfamily] == 'Archlinux'
elsif facts[:osfamily] == 'Archlinux'
confdir = '/etc/puppetlabs/puppet'
end

let :facts do
default_facts.merge(additional_facts)
facts.merge(additional_facts)
end

describe 'when runmode is not systemd' do
Expand Down Expand Up @@ -77,9 +65,9 @@

if Puppet.version < '4.0'
bindir = '/usr/bin'
elsif os_facts[:osfamily] == 'FreeBSD'
elsif facts[:osfamily] == 'FreeBSD'
bindir = '/usr/local/bin'
elsif os_facts[:osfamily] == 'Archlinux'
elsif facts[:osfamily] == 'Archlinux'
bindir = '/usr/bin'
else
bindir = '/opt/puppetlabs/bin'
Expand Down Expand Up @@ -111,7 +99,7 @@
})
end
else
it { should raise_error(Puppet::Error, /Runmode of systemd.timer not supported on #{os_facts[:kernel]} operating systems!/) }
it { should raise_error(Puppet::Error, /Runmode of systemd.timer not supported on #{facts[:kernel]} operating systems!/) }
end
end
end
Expand Down
24 changes: 7 additions & 17 deletions spec/classes/puppet_agent_spec.rb
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
require 'spec_helper'

describe 'puppet::agent' do
on_supported_os.each do |os, os_facts|
next if only_test_os() and not only_test_os.include?(os)
next if exclude_test_os() and exclude_test_os.include?(os)
on_os_under_test.each do |os, facts|
context "on #{os}" do
let (:default_facts) do
os_facts.merge({
:clientcert => 'puppetmaster.example.com',
:concat_basedir => '/nonexistant',
:fqdn => 'puppetmaster.example.com',
:puppetversion => Puppet.version,
}) end

if Puppet.version < '4.0'
client_package = 'puppet'
confdir = '/etc/puppet'
case os_facts[:osfamily]
case facts[:osfamily]
when 'FreeBSD'
client_package = 'puppet38'
confdir = '/usr/local/etc/puppet'
Expand All @@ -29,7 +19,7 @@
client_package = 'puppet-agent'
confdir = '/etc/puppetlabs/puppet'
additional_facts = {:rubysitedir => '/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0'}
case os_facts[:osfamily]
case facts[:osfamily]
when 'FreeBSD'
client_package = 'puppet4'
confdir = '/usr/local/etc/puppet'
Expand All @@ -42,7 +32,7 @@
end

let :facts do
default_facts.merge(additional_facts)
facts.merge(additional_facts)
end

describe 'with no custom parameters' do
Expand All @@ -62,7 +52,7 @@
end

it do
should contain_puppet__config__agent('server').with({'value' => 'puppetmaster.example.com'})
should contain_puppet__config__agent('server').with_value('foo.example.com')
end

it do
Expand All @@ -84,7 +74,7 @@
describe 'global puppetmaster overrides fqdn' do
let(:pre_condition) { "class {'puppet': agent => true}" }
let :facts do
default_facts.merge({:puppetmaster => 'mymaster.example.com'})
facts.merge({:puppetmaster => 'mymaster.example.com'})
end
it do
should contain_puppet__config__agent('server').with({'value' => 'mymaster.example.com'})
Expand All @@ -94,7 +84,7 @@
describe 'puppetmaster parameter overrides global puppetmaster' do
let(:pre_condition) { "class {'puppet': agent => true, puppetmaster => 'mymaster.example.com'}" }
let :facts do
default_facts.merge({:puppetmaster => 'global.example.com'})
facts.merge({:puppetmaster => 'global.example.com'})
end
it do
should contain_puppet__config__agent('server').with({'value' => 'mymaster.example.com'})
Expand Down
16 changes: 3 additions & 13 deletions spec/classes/puppet_config_spec.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
require 'spec_helper'

describe 'puppet::config' do
on_supported_os.each do |os, os_facts|
next if only_test_os() and not only_test_os.include?(os)
next if exclude_test_os() and exclude_test_os.include?(os)
on_os_under_test.each do |os, facts|
context "on #{os}" do
let (:default_facts) do
os_facts.merge({
:concat_basedir => '/foo/bar',
:domain => 'example.org',
:fqdn => 'host.example.com',
:puppetversion => Puppet.version,
}) end

if Puppet.version < '4.0'
codedir = '/etc/puppet'
confdir = '/etc/puppet'
Expand All @@ -33,7 +23,7 @@
additional_facts = {:rubysitedir => '/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0'}
end

case os_facts[:osfamily]
case facts[:osfamily]
when 'FreeBSD'
codedir = '/usr/local/etc/puppet'
confdir = '/usr/local/etc/puppet'
Expand All @@ -53,7 +43,7 @@
end

let :facts do
default_facts.merge(additional_facts)
facts.merge(additional_facts).merge({:domain => 'example.org'})
end

describe 'with default parameters' do
Expand Down