3 describe 'apt::setting' do
4 let(:pre_condition) { 'class { "apt": }' }
7 :os => { :distro => { :codename => 'wheezy' }, :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
8 :lsbdistrelease => '7.0',
9 :lsbdistcodename => 'wheezy',
10 :operatingsystem => 'Debian',
11 :osfamily => 'Debian',
12 :lsbdistid => 'Debian',
13 :puppetversion => Puppet.version,
16 let(:title) { 'conf-teddybear' }
18 let(:default_params) { { :content => 'di' } }
20 describe 'when using the defaults' do
21 context 'without source or content' do
23 expect { subject.call }.to raise_error(Puppet::Error, /needs either of /)
27 context 'with title=conf-teddybear ' do
28 let(:params) { default_params }
29 it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]') }
32 context 'with title=pref-teddybear' do
33 let(:title) { 'pref-teddybear' }
34 let(:params) { default_params }
35 it { is_expected.to contain_file('/etc/apt/preferences.d/teddybear.pref').that_notifies('Class[Apt::Update]') }
38 context 'with title=list-teddybear' do
39 let(:title) { 'list-teddybear' }
40 let(:params) { default_params }
41 it { is_expected.to contain_file('/etc/apt/sources.list.d/teddybear.list').that_notifies('Class[Apt::Update]') }
44 context 'with source' do
45 let(:params) { { :source => 'puppet:///la/die/dah' } }
47 is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with({
52 :source => "#{params[:source]}",
56 context 'with content' do
57 let(:params) { default_params }
58 it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with({
63 :content => "#{params[:content]}",
68 describe 'settings requiring settings, MODULES-769' do
69 let(:pre_condition) do
71 apt::setting { "list-teddybear": content => "foo" }
74 let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version, } }
75 let(:title) { 'conf-teddybear' }
76 let(:default_params) { { :content => 'di' } }
78 let(:params) { default_params.merge({ :require => 'Apt::Setting[list-teddybear]' }) }
80 it { is_expected.to compile.with_all_deps }
83 describe 'when trying to pull one over' do
84 context 'with source and content' do
85 let(:params) { default_params.merge({ :source => 'la' }) }
87 expect { subject.call }.to raise_error(Puppet::Error, /cannot have both /)
91 context 'with title=ext-teddybear' do
92 let(:title) { 'ext-teddybear' }
93 let(:params) { default_params }
95 expect { subject.call }.to raise_error(Puppet::Error, /must start with either/)
99 context 'with ensure=banana' do
100 let(:params) { default_params.merge({ :ensure => 'banana' }) }
102 expect { subject.call }.to raise_error(Puppet::Error, /Enum\['absent', 'file', 'present'\], got 'banana'/)
106 context 'with priority=1.2' do
107 let(:params) { default_params.merge({ :priority => 1.2 }) }
108 if Puppet::Util::Package.versioncmp(Puppet.version, '4.0') >= 0 || ENV["FUTURE_PARSER"] == 'yes'
109 it { is_expected.to compile.and_raise_error(/expects a value of type/) }
111 it { is_expected.to compile.and_raise_error(/priority must be an integer or a zero-padded integer/) }
116 describe 'with priority=100' do
117 let(:params) { default_params.merge({ :priority => 100 }) }
118 it { is_expected.to contain_file('/etc/apt/apt.conf.d/100teddybear').that_notifies('Class[Apt::Update]') }
121 describe 'with ensure=absent' do
122 let(:params) { default_params.merge({ :ensure => 'absent' }) }
123 it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with({