Skip to content

Commit

Permalink
Merge pull request #442 from mhaskel/add_base_name
Browse files Browse the repository at this point in the history
Add base_name parameter to apt::setting
  • Loading branch information
daenney committed Feb 25, 2015
2 parents fd71aed + 1236ecf commit 1c0c6f1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion manifests/setting.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
define apt::setting (
$setting_type,
$base_name = $title,
$priority = 50,
$ensure = file,
$source = undef,
Expand All @@ -19,6 +20,7 @@

validate_re($setting_type, ['conf', 'pref', 'list'])
validate_re($ensure, ['file', 'present', 'absent'])
validate_string($base_name)

unless is_integer($priority) {
# need this to allow zero-padded priority.
Expand All @@ -42,7 +44,7 @@
$_path = $::apt::config_files[$setting_type]['path']
$_ext = $::apt::config_files[$setting_type]['ext']

file { "${_path}/${_priority}${title}${_ext}":
file { "${_path}/${_priority}${base_name}${_ext}":
ensure => $ensure,
owner => $_file['owner'],
group => $_file['group'],
Expand Down
12 changes: 12 additions & 0 deletions spec/defines/setting_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@
it { is_expected.to contain_file('/etc/apt/apt.conf.d/100teddybear') }
end

describe 'with base_name=puppy' do
let(:params) { default_params.merge({ :base_name => 'puppy' }) }
it { should contain_file('/etc/apt/apt.conf.d/50puppy') }
end

describe 'with base_name=true' do
let(:params) { default_params.merge({ :base_name => true }) }
it do
expect { should compile }.to raise_error(Puppet::Error, /not a string/)
end
end

describe 'with ensure=absent' do
let(:params) { default_params.merge({ :ensure => 'absent' }) }
it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').with({
Expand Down

0 comments on commit 1c0c6f1

Please sign in to comment.