Skip to content

Commit

Permalink
add unit tests of mdadm's service_{ensure,enable} params
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Hoblitt committed May 21, 2014
1 parent 7ba06ea commit 9c9b7c7
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,15 @@ unless the `$::mdadm_arrays` fact lists `md` arrays. If this parameter is set t

`String` defaults to 'running'

Valid strings are: 'running', 'stopped'
Sets the state of the `mdmonitor` service. Valid strings are: 'running',
'stopped'

##### `service_enable`

`Bool` defaults to 'true'

Enables/disables the `mdmonitor` service on boot.

##### `raid_check_manage`

`Bool` defaults to `true`
Expand Down
76 changes: 76 additions & 0 deletions spec/unit/classes/mdadm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,82 @@
end
end # service_force

context 'service_ensure =>' do
# we need to set service_force => true to disable the automatic service
# setup based on the existance of the ::mdadm_arrays fact
context 'running' do
let(:params) {{ :service_force => true, :service_ensure => 'running' }}

it do
should contain_service('mdmonitor').with({
:ensure => 'running',
:hasrestart => true,
:hasstatus => true,
:enable => true,
})
end
end

context 'stopped' do
let(:params) {{:service_force => true, :service_ensure => 'stopped' }}

it do
should contain_service('mdmonitor').with({
:ensure => 'stopped',
:hasrestart => true,
:hasstatus => true,
:enable => true,
})
end
end

context 'foo' do
let(:params) {{ :service_ensure => 'foo' }}

it 'should fail' do
expect { should }.to raise_error(/does not match/)
end
end
end # service_ensure

context 'service_enable =>' do
# we need to set service_force => true to disable the automatic service
# setup based on the existance of the ::mdadm_arrays fact
context 'true' do
let(:params) {{ :service_force => true, :service_enable => true }}

it do
should contain_service('mdmonitor').with({
:ensure => 'running',
:hasrestart => true,
:hasstatus => true,
:enable => true,
})
end
end

context 'false' do
let(:params) {{:service_force => true, :service_enable => false }}

it do
should contain_service('mdmonitor').with({
:ensure => 'running',
:hasrestart => true,
:hasstatus => true,
:enable => false,
})
end
end

context 'foo' do
let(:params) {{ :service_enable => 'foo' }}

it 'should fail' do
expect { should }.to raise_error(/is not a boolean/)
end
end
end # service_enable

context 'raid_check_manage =>' do
context 'true' do
let(:params) {{ :raid_check_manage => true }}
Expand Down

0 comments on commit 9c9b7c7

Please sign in to comment.