Merge pull request #435 from mhaskel/setting_fix

Type is a reserved word in puppet 4
This commit is contained in:
Daniele Sluijters 2015-02-22 00:22:59 +01:00
commit 7e7e3e2f50
2 changed files with 17 additions and 17 deletions

View file

@ -1,5 +1,5 @@
define apt::setting ( define apt::setting (
$type, $setting_type,
$priority = 50, $priority = 50,
$ensure = file, $ensure = file,
$source = undef, $source = undef,
@ -17,7 +17,7 @@ define apt::setting (
fail('apt::setting needs either of content or source') fail('apt::setting needs either of content or source')
} }
validate_re($type, ['conf', 'pref', 'list']) validate_re($setting_type, ['conf', 'pref', 'list'])
validate_re($ensure, ['file', 'present', 'absent']) validate_re($ensure, ['file', 'present', 'absent'])
unless is_integer($priority) { unless is_integer($priority) {
@ -32,14 +32,14 @@ define apt::setting (
validate_string($content) validate_string($content)
} }
if $type == 'list' { if $setting_type == 'list' {
$_priority = '' $_priority = ''
} else { } else {
$_priority = $priority $_priority = $priority
} }
$_path = $::apt::config_files[$type]['path'] $_path = $::apt::config_files[$setting_type]['path']
$_ext = $::apt::config_files[$type]['ext'] $_ext = $::apt::config_files[$setting_type]['ext']
file { "${_path}/${_priority}${title}${_ext}": file { "${_path}/${_priority}${title}${_ext}":
ensure => $ensure, ensure => $ensure,

View file

@ -5,39 +5,39 @@ describe 'apt::setting' do
let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } } let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
let(:title) { 'teddybear' } let(:title) { 'teddybear' }
let(:default_params) { { :type => 'conf', :content => 'di' } } let(:default_params) { { :setting_type => 'conf', :content => 'di' } }
describe 'when using the defaults' do describe 'when using the defaults' do
context 'without type' do context 'without setting_type' do
it do it do
expect { should compile }.to raise_error(Puppet::Error, /Must pass type /) expect { should compile }.to raise_error(Puppet::Error, /Must pass setting_type /)
end end
end end
context 'without source or content' do context 'without source or content' do
let(:params) { { :type => 'conf' } } let(:params) { { :setting_type => 'conf' } }
it do it do
expect { should compile }.to raise_error(Puppet::Error, /needs either of /) expect { should compile }.to raise_error(Puppet::Error, /needs either of /)
end end
end end
context 'with type=conf' do context 'with setting_type=conf' do
let(:params) { default_params } let(:params) { default_params }
it { should contain_file('/etc/apt/apt.conf.d/50teddybear') } it { should contain_file('/etc/apt/apt.conf.d/50teddybear') }
end end
context 'with type=pref' do context 'with setting_type=pref' do
let(:params) { { :type => 'pref', :content => 'di' } } let(:params) { { :setting_type => 'pref', :content => 'di' } }
it { should contain_file('/etc/apt/preferences.d/50teddybear') } it { should contain_file('/etc/apt/preferences.d/50teddybear') }
end end
context 'with type=list' do context 'with setting_type=list' do
let(:params) { { :type => 'list', :content => 'di' } } let(:params) { { :setting_type => 'list', :content => 'di' } }
it { should contain_file('/etc/apt/sources.list.d/teddybear.list') } it { should contain_file('/etc/apt/sources.list.d/teddybear.list') }
end end
context 'with source' do context 'with source' do
let(:params) { { :type => 'conf', :source => 'puppet:///la/die/dah' } } let(:params) { { :setting_type => 'conf', :source => 'puppet:///la/die/dah' } }
it { it {
should contain_file('/etc/apt/apt.conf.d/50teddybear').with({ should contain_file('/etc/apt/apt.conf.d/50teddybear').with({
:ensure => 'file', :ensure => 'file',
@ -68,8 +68,8 @@ describe 'apt::setting' do
end end
end end
context 'with type=ext' do context 'with setting_type=ext' do
let(:params) { default_params.merge({ :type => 'ext' }) } let(:params) { default_params.merge({ :setting_type => 'ext' }) }
it do it do
expect { should compile }.to raise_error(Puppet::Error, /"ext" does not /) expect { should compile }.to raise_error(Puppet::Error, /"ext" does not /)
end end