Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #37 from Phil-Friderici/puppet-lint
Browse files Browse the repository at this point in the history
Satisfy puppet-lint
  • Loading branch information
petems committed Jan 8, 2016
2 parents 5c372cb + f3a5436 commit 8dc8424
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion manifests/files.pp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
{
# Parameter validation
validate_re($ensure, ['^absent$', '^present$'], "Invalid ensure: ${ensure} - (Must be 'present' or 'absent')")
validate_re($cmd, ['^dd$', '^fallocate$'], "Invalid cmd: ${cmd} - (Must be 'dd' or 'fallocate')")
validate_string($swapfile)
$swapfilesize_mb = to_bytes($swapfilesize) / 1000000
validate_bool($add_mount)
Expand All @@ -61,6 +60,9 @@
'fallocate': {
Exec["Create swap file ${swapfile}"] { command => "/usr/bin/fallocate -l ${swapfilesize_mb}M ${swapfile}" }
}
default: {
fail("Invalid cmd: ${cmd} - (Must be 'dd' or 'fallocate')")
}
}
file { $swapfile:
owner => root,
Expand Down
11 changes: 11 additions & 0 deletions spec/defines/files_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,15 @@
)
end
end

context 'with cmd set to invalid value' do
let(:params) do
{
:cmd => 'invalid',
}
end
it 'should fail' do
expect { should contain_class(subject) }.to raise_error(Puppet::Error, /Invalid cmd: invalid - \(Must be \'dd\' or \'fallocate\'\)/)
end
end
end

0 comments on commit 8dc8424

Please sign in to comment.