Unit tests for the tweaks class
This change implements tests for the tweaks class. Change-Id: Ic07671eaf17bb622cd906670901787aaa8b397dd Related-Bug: #1507751
This commit is contained in:
parent
9a17ca6af1
commit
add100a3a5
|
@ -0,0 +1,3 @@
|
|||
fixtures:
|
||||
symlinks:
|
||||
'tweaks': "#{source_dir}"
|
|
@ -0,0 +1 @@
|
|||
spec/fixtures
|
|
@ -0,0 +1,22 @@
|
|||
source 'https://rubygems.org'
|
||||
|
||||
group :development, :test do
|
||||
gem 'puppetlabs_spec_helper', :require => 'false'
|
||||
gem 'rspec-puppet', '~> 2.2.0', :require => 'false'
|
||||
gem 'metadata-json-lint', :require => 'false'
|
||||
gem 'puppet-lint-param-docs', :require => 'false'
|
||||
gem 'puppet-lint-absolute_classname-check', :require => 'false'
|
||||
gem 'puppet-lint-absolute_template_path', :require => 'false'
|
||||
gem 'puppet-lint-trailing_newline-check', :require => 'false'
|
||||
gem 'puppet-lint-unquoted_string-check', :require => 'false'
|
||||
gem 'puppet-lint-leading_zero-check', :require => 'false'
|
||||
gem 'puppet-lint-variable_contains_upcase', :require => 'false'
|
||||
gem 'puppet-lint-numericvariable', :require => 'false'
|
||||
gem 'json', :require => 'false'
|
||||
end
|
||||
|
||||
if puppetversion = ENV['PUPPET_GEM_VERSION']
|
||||
gem 'puppet', puppetversion, :require => false
|
||||
else
|
||||
gem 'puppet', :require => false
|
||||
end
|
|
@ -0,0 +1,22 @@
|
|||
require 'puppetlabs_spec_helper/rake_tasks'
|
||||
require 'puppet-lint/tasks/puppet-lint'
|
||||
require 'puppet-syntax/tasks/puppet-syntax'
|
||||
|
||||
PuppetSyntax.exclude_paths ||= []
|
||||
PuppetSyntax.exclude_paths << "spec/fixtures/**/*"
|
||||
PuppetSyntax.exclude_paths << "pkg/**/*"
|
||||
PuppetSyntax.exclude_paths << "vendor/**/*"
|
||||
|
||||
Rake::Task[:lint].clear
|
||||
PuppetLint::RakeTask.new :lint do |config|
|
||||
config.ignore_paths = ["spec/**/*.pp", "vendor/**/*.pp"]
|
||||
config.fail_on_warnings = false # TODO(aschultz): fix warnings
|
||||
config.log_format = '%{path}:%{linenumber}:%{KIND}: %{message}'
|
||||
config.disable_checks = [
|
||||
"80chars",
|
||||
"class_inherits_from_params_class",
|
||||
"class_parameter_defaults",
|
||||
"only_variable_string",
|
||||
"autoloader_layout", # TODO(aschultz): this is from included defines in classes, should be fixed and this should be removed.
|
||||
]
|
||||
end
|
|
@ -0,0 +1,47 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'tweaks::apache_wrappers' do
|
||||
|
||||
let(:default_params) { {
|
||||
} }
|
||||
|
||||
shared_examples_for 'tweaks::apache_wrappers configuration' do
|
||||
let :params do
|
||||
default_params
|
||||
end
|
||||
|
||||
|
||||
context 'with valid params' do
|
||||
let :params do
|
||||
default_params.merge({})
|
||||
end
|
||||
|
||||
it 'configures with the default params' do
|
||||
should contain_class('tweaks::apache_wrappers')
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian',
|
||||
:operatingsystem => 'Debian',
|
||||
:hostname => 'hostname.example.com', }
|
||||
end
|
||||
|
||||
it_configures 'tweaks::apache_wrappers configuration'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat',
|
||||
:operatingsystem => 'RedHat',
|
||||
:hostname => 'hostname.example.com', }
|
||||
end
|
||||
|
||||
it_configures 'tweaks::apache_wrappers configuration'
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'tweaks::ubuntu_service_override' do
|
||||
let(:title) { 'something' }
|
||||
|
||||
let(:default_params) { {
|
||||
:service_name => title,
|
||||
:package_name => title
|
||||
} }
|
||||
|
||||
shared_examples_for 'tweaks::ubuntu_service_override configuration' do
|
||||
let :params do
|
||||
default_params
|
||||
end
|
||||
|
||||
|
||||
context 'with valid params' do
|
||||
let :params do
|
||||
default_params.merge({})
|
||||
end
|
||||
|
||||
it 'configures with the default params' do
|
||||
should contain_tweaks__ubuntu_service_override(title)
|
||||
if facts[:operatingsystem] == 'Ubuntu'
|
||||
should contain_file("create_#{params[:service_name]}_override").with(
|
||||
:path => "/etc/init/#{title}.override")
|
||||
should contain_exec("remove_#{params[:service_name]}_override")
|
||||
else
|
||||
should_not contain_file("create_#{params[:service_name]}_override").with(
|
||||
:path => "/etc/init.d/#{title}.override")
|
||||
should_not contain_exec("remove_#{params[:service_name]}_override")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian',
|
||||
:operatingsystem => 'Debian',
|
||||
:hostname => 'hostname.example.com', }
|
||||
end
|
||||
|
||||
it_configures 'tweaks::ubuntu_service_override configuration'
|
||||
end
|
||||
|
||||
context 'on Ubuntu platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian',
|
||||
:operatingsystem => 'Ubuntu',
|
||||
:hostname => 'hostname.example.com', }
|
||||
end
|
||||
|
||||
it_configures 'tweaks::ubuntu_service_override configuration'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat',
|
||||
:operatingsystem => 'RedHat',
|
||||
:hostname => 'hostname.example.com', }
|
||||
end
|
||||
|
||||
it_configures 'tweaks::ubuntu_service_override configuration'
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
shared_examples_for "a Puppet::Error" do |description|
|
||||
it "with message matching #{description.inspect}" do
|
||||
expect { is_expected.to have_class_count(1) }.to raise_error(Puppet::Error, description)
|
||||
end
|
||||
end
|
|
@ -0,0 +1,9 @@
|
|||
require 'puppetlabs_spec_helper/module_spec_helper'
|
||||
require 'shared_examples'
|
||||
|
||||
RSpec.configure do |c|
|
||||
c.alias_it_should_behave_like_to :it_configures, 'configures'
|
||||
c.alias_it_should_behave_like_to :it_raises, 'raises'
|
||||
end
|
||||
|
||||
at_exit { RSpec::Puppet::Coverage.report! }
|
|
@ -37,7 +37,6 @@ rsyslog
|
|||
ssh
|
||||
stdlib
|
||||
sysctl
|
||||
tweaks
|
||||
vcsrepo
|
||||
vmware
|
||||
xinetd
|
||||
|
|
Loading…
Reference in New Issue