Skip to content

Commit

Permalink
merge mdadm_config_spec.rb into mdadm_spec.rb
Browse files Browse the repository at this point in the history
Since we're now only testing the public API of the mdadm class.
  • Loading branch information
Joshua Hoblitt committed May 21, 2014
1 parent 5d1b8d3 commit ef0e227
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 95 deletions.
93 changes: 0 additions & 93 deletions spec/unit/classes/mdadm_config_spec.rb

This file was deleted.

81 changes: 79 additions & 2 deletions spec/unit/classes/mdadm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

shared_examples 'mdadm' do
it { should contain_package('mdadm').with_ensure('present') }
it { should contain_class('mdadm::params') }
it { should contain_class('mdadm::mdmonitor') }
it do
should contain_service('mdmonitor').with({
:ensure => 'running',
Expand Down Expand Up @@ -37,8 +35,87 @@
with_content(/REPAIR_DEVS=""/).
with_content(/SKIP_DEVS=""/)
end
it { should_not contain_augeas('mdadm.conf mailaddr') }
end # no params

# config_file_manage should have no visiable behavior without
# config_file_options
context 'config_file_manage =>' do
context 'true' do
let(:params) {{ :config_file_manage => true }}

it { should_not contain_augeas('mdadm.conf mailaddr') }
end

context 'false' do
let(:params) {{ :config_file_manage => false }}

it { should_not contain_augeas('mdadm.conf mailaddr') }
end

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

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

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

it { should_not contain_augeas('mdadm.conf mailaddr') }
end

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

it { should contain_augeas('mdadm.conf mailaddr') }

# mdadm.conf already has a MAILADDR line
describe_augeas 'mdadm.conf mailaddr', :lens => 'mdadm_conf', :target => 'etc/mdadm.conf' do
it 'should change MAILADDR' do
should execute.with_change
aug_get('mailaddr/value').should == 'foo'
should execute.idempotently
end
end

# mdadm.conf does not have a MAILADDR line
describe_augeas 'mdadm.conf mailaddr', :lens => 'mdadm_conf', :target => 'etc/mdadm.conf', :fixture => 'etc/mdadm.conf-no_mailaddr' do
it 'should change MAILADDR' do
should execute.with_change
aug_get('mailaddr/value').should == 'foo'
should execute.idempotently
end
end

context 'and config_file_manage =>' do
context 'true' do
before { params[:config_file_manage] = true }

it { should contain_augeas('mdadm.conf mailaddr') }
end

context 'false' do
before { params[:config_file_manage] = false }

it { should_not contain_augeas('mdadm.conf mailaddr') }
end
end
end # { mailaddr => foo }

context 'undef' do
let(:params) {{ :config_file_options => nil }}

it 'should fail' do
expect { should }.to raise_error(/is not a Hash/)
end
end
end # options =>

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

0 comments on commit ef0e227

Please sign in to comment.