Skip to content

Commit

Permalink
Fix bug when package_ensure was set to absent.
Browse files Browse the repository at this point in the history
* Service[memcached] `enable` was left to `true`
  • Loading branch information
riton committed Jul 16, 2014
1 parent 4b29e75 commit c76b78f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
4 changes: 3 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@

if $package_ensure == 'absent' {
$service_ensure = 'stopped'
$service_enable = false
} else {
$service_ensure = 'running'
$service_enable = true
}

package { $memcached::params::package_name:
Expand Down Expand Up @@ -78,7 +80,7 @@

service { $memcached::params::service_name:
ensure => $service_ensure,
enable => true,
enable => $service_enable,
hasrestart => true,
hasstatus => $memcached::params::service_hasstatus,
}
Expand Down
27 changes: 21 additions & 6 deletions spec/classes/memcached_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@
:verbosity => 'vvv',
:install_dev => true,
:processorcount => 1
},
{
:package_ensure => 'absent',
:install_dev => true
}
].each do |param_set|
describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
Expand Down Expand Up @@ -133,12 +137,21 @@
'group' => 'root'
)}

it { should contain_service("memcached").with(
'ensure' => 'running',
'enable' => true,
'hasrestart' => true,
'hasstatus' => false
)}
it {
if param_hash[:package_ensure] == 'absent'
should contain_service("memcached").with(
'ensure' => 'stopped',
'enable' => false
)
else
should contain_service("memcached").with(
'ensure' => 'running',
'enable' => true,
'hasrestart' => true,
'hasstatus' => false
)
end
}

it 'should compile the template based on the class parameters' do
content = param_value(
Expand Down Expand Up @@ -185,3 +198,5 @@
end
end
end

# vim: expandtab shiftwidth=2 softtabstop=2

0 comments on commit c76b78f

Please sign in to comment.