Skip to content

Commit

Permalink
The base class must be defined first so the parameters are known
Browse files Browse the repository at this point in the history
This also implies the dependency for the tests needed to be changed.
Because of the changed dependency, tests needed some extra facts to please
the concat module.
  • Loading branch information
Steven Post committed Mar 27, 2015
1 parent 4290182 commit 296aab5
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 18 deletions.
3 changes: 0 additions & 3 deletions manifests/dev.pp
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
class apache::dev {
if $::osfamily == 'FreeBSD' and !defined(Class['apache::package']) {
fail('apache::dev requires apache::package; please include apache or apache::package class first')
}
include ::apache::params
$packages = $::apache::params::dev_packages
if $packages { # FreeBSD doesn't have dev packages to install
Expand Down
6 changes: 6 additions & 0 deletions manifests/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
$ensure = 'present',
$mpm_module = $::apache::params::mpm_module,
) inherits ::apache::params {

# The base class must be included first because it is used by parameter defaults
if ! defined(Class['apache']) {
fail('You must include the apache base class before using any apache defined resources')
}

case $::osfamily {
'FreeBSD': {
case $mpm_module {
Expand Down
29 changes: 23 additions & 6 deletions spec/classes/dev_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
require 'spec_helper'

describe 'apache::dev', :type => :class do
let(:pre_condition) {[
'include apache'
]}
context "on a Debian OS" do
let :facts do
{
Expand All @@ -9,6 +12,10 @@
:operatingsystem => 'Debian',
:operatingsystemrelease => '6',
:is_pe => false,
:concat_basedir => '/foo',
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin',
:kernel => 'Linux'
}
end
it { is_expected.to contain_class("apache::params") }
Expand All @@ -25,6 +32,10 @@
:operatingsystem => 'Ubuntu',
:operatingsystemrelease => '14.04',
:is_pe => false,
:concat_basedir => '/foo',
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin',
:kernel => 'Linux'
}
end
it { is_expected.to contain_package("apache2-dev") }
Expand All @@ -36,36 +47,42 @@
:operatingsystem => 'RedHat',
:operatingsystemrelease => '6',
:is_pe => false,
:concat_basedir => '/foo',
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin',
:kernel => 'Linux'
}
end
it { is_expected.to contain_class("apache::params") }
it { is_expected.to contain_package("httpd-devel") }
end
context "on a FreeBSD OS" do
let :pre_condition do
'include apache::package'
end
let :facts do
{
:osfamily => 'FreeBSD',
:operatingsystem => 'FreeBSD',
:operatingsystemrelease => '9',
:is_pe => false,
:concat_basedir => '/foo',
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin',
:kernel => 'FreeBSD'
}
end
it { is_expected.to contain_class("apache::params") }
end
context "on a Gentoo OS" do
let :pre_condition do
'include apache::package'
end
let :facts do
{
:osfamily => 'Gentoo',
:operatingsystem => 'Gentoo',
:operatingsystemrelease => '3.16.1-gentoo',
:concat_basedir => '/dne',
:is_pe => false,
:concat_basedir => '/foo',
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin',
:kernel => 'Linux'
}
end
it { is_expected.to contain_class("apache::params") }
Expand Down
20 changes: 11 additions & 9 deletions spec/classes/mod/dev_spec.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
require 'spec_helper'

describe 'apache::mod::dev', :type => :class do
let(:pre_condition) {[
'include apache'
]}
[
['RedHat', '6', 'Santiago'],
['Debian', '6', 'squeeze'],
['FreeBSD', '9', 'FreeBSD'],
].each do |osfamily, operatingsystemrelease, lsbdistcodename|
if osfamily == 'FreeBSD'
let :pre_condition do
'include apache::package'
end
end
['RedHat', '6', 'Santiago', 'Linux'],
['Debian', '6', 'squeeze', 'Linux'],
['FreeBSD', '9', 'FreeBSD', 'FreeBSD'],
].each do |osfamily, operatingsystemrelease, lsbdistcodename, kernel|
context "on a #{osfamily} OS" do
let :facts do
{
Expand All @@ -19,6 +17,10 @@
:operatingsystem => osfamily,
:operatingsystemrelease => operatingsystemrelease,
:is_pe => false,
:concat_basedir => '/foo',
:id => 'root',
:path => '/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin',
:kernel => kernel
}
end
it { is_expected.to contain_class('apache::dev') }
Expand Down

0 comments on commit 296aab5

Please sign in to comment.