Run spec tests on all supported OS
Also add resource coverage
This commit is contained in:
parent
ee0e095ea2
commit
3dd198e706
@ -1,74 +1,46 @@
|
||||
# ex: syntax=ruby ts=2 sw=2 si et
|
||||
require 'spec_helper'
|
||||
require 'pp'
|
||||
|
||||
describe 'bind' do
|
||||
context "on a Debian OS" do
|
||||
let :facts do
|
||||
{
|
||||
:concat_basedir => '/wtf',
|
||||
:osfamily => 'Debian',
|
||||
:os => {
|
||||
:family => 'Debian',
|
||||
},
|
||||
:operatingsystem => 'Debian'
|
||||
}
|
||||
on_supported_os.each do |os, facts|
|
||||
context "on #{os}" do
|
||||
let (:facts) {facts}
|
||||
case facts[:os]['family']
|
||||
when 'Debian'
|
||||
expected_bind_tools_pkg = 'dnsutils'
|
||||
expected_bind_pkg = 'bind9'
|
||||
expected_bind_service = 'bind9'
|
||||
expected_named_conf = '/etc/bind/named.conf'
|
||||
when 'RedHat'
|
||||
expected_bind_tools_pkg = 'bind-utils'
|
||||
expected_bind_pkg = 'bind'
|
||||
expected_bind_service = 'named'
|
||||
expected_named_conf = '/etc/named.conf'
|
||||
end
|
||||
context 'with defaults for all parameters' do
|
||||
it { is_expected.to compile.with_all_deps }
|
||||
it do
|
||||
is_expected.to contain_package('bind-tools').with({
|
||||
ensure: 'present',
|
||||
name: expected_bind_tools_pkg
|
||||
})
|
||||
end
|
||||
it do
|
||||
is_expected.to contain_package('bind').with({
|
||||
ensure: 'latest',
|
||||
name: expected_bind_pkg
|
||||
})
|
||||
end
|
||||
it { is_expected.to contain_file(expected_named_conf).that_requires('Package[bind]') }
|
||||
it { is_expected.to contain_file(expected_named_conf).that_notifies('Service[bind]') }
|
||||
it do
|
||||
is_expected.to contain_service('bind').with({
|
||||
ensure: 'running',
|
||||
name: expected_bind_service
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
it { is_expected.to compile }
|
||||
it do
|
||||
should contain_package('bind-tools').with({
|
||||
ensure: 'present',
|
||||
name: 'dnsutils'
|
||||
})
|
||||
end
|
||||
it do
|
||||
should contain_package('bind').with({
|
||||
ensure: 'latest',
|
||||
name: 'bind9'
|
||||
})
|
||||
end
|
||||
|
||||
it { should contain_file('/etc/bind/named.conf').that_requires('Package[bind]') }
|
||||
it { should contain_file('/etc/bind/named.conf').that_notifies('Service[bind]') }
|
||||
|
||||
it {
|
||||
should contain_service('bind').with({
|
||||
ensure: 'running',
|
||||
name: 'bind9'
|
||||
})
|
||||
}
|
||||
end
|
||||
context "on a RedHat OS" do
|
||||
let :facts do
|
||||
{
|
||||
:concat_basedir => '/wtf',
|
||||
:osfamily => 'RedHat',
|
||||
:os => {
|
||||
:family => 'RedHat',
|
||||
},
|
||||
:operatingsystem => 'CentOS'
|
||||
}
|
||||
end
|
||||
it {
|
||||
should contain_package('bind-tools').with({
|
||||
'ensure' => 'present',
|
||||
'name' => 'bind-utils'
|
||||
})
|
||||
}
|
||||
it {
|
||||
should contain_package('bind').with({
|
||||
'ensure' => 'latest',
|
||||
'name' => 'bind'
|
||||
})
|
||||
}
|
||||
|
||||
it { should contain_file('/etc/named.conf').that_requires('Package[bind]') }
|
||||
it { should contain_file('/etc/named.conf').that_notifies('Service[bind]') }
|
||||
|
||||
it {
|
||||
should contain_service('bind').with({
|
||||
'ensure' => 'running',
|
||||
'name' => 'named'
|
||||
})
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,21 +1,18 @@
|
||||
|
||||
require 'puppetlabs_spec_helper/module_spec_helper'
|
||||
require 'rspec-puppet-facts'
|
||||
require 'rspec-puppet'
|
||||
|
||||
include RspecPuppetFacts
|
||||
|
||||
require 'simplecov'
|
||||
require 'simplecov-console'
|
||||
|
||||
SimpleCov.start do
|
||||
add_filter '/spec'
|
||||
add_filter '/vendor'
|
||||
formatter SimpleCov::Formatter::MultiFormatter.new([
|
||||
SimpleCov::Formatter::HTMLFormatter,
|
||||
SimpleCov::Formatter::Console
|
||||
])
|
||||
end
|
||||
|
||||
RSpec.configure do |c|
|
||||
c.hiera_config = File.expand_path(File.join(__FILE__, '../fixtures/hiera.yaml'))
|
||||
c.after(:suite) do
|
||||
RSpec::Puppet::Coverage.report!
|
||||
end
|
||||
end
|
||||
|
||||
# Deal with missing fact in puppet firewall module
|
||||
add_custom_fact :concat_basedir, '/tmp/concat/basedir'
|
||||
|
||||
Loading…
Reference in New Issue
Block a user