3 describe 'apt::setting' do
4 let(:pre_condition) { 'class { "apt": }' }
5 let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } }
6 let(:title) { 'conf-teddybear' }
8 let(:default_params) { { :content => 'di' } }
10 describe 'when using the defaults' do
11 context 'without source or content' do
13 expect { is_expected.to compile }.to raise_error(Puppet::Error, /needs either of /)
17 context 'with title=conf-teddybear ' do
18 let(:params) { default_params }
19 it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]') }
22 context 'with title=pref-teddybear' do
23 let(:title) { 'pref-teddybear' }
24 let(:params) { default_params }
25 it { is_expected.to contain_file('/etc/apt/preferences.d/50teddybear').that_notifies('Exec[apt_update]') }
28 context 'with title=list-teddybear' do
29 let(:title) { 'list-teddybear' }
30 let(:params) { default_params }
31 it { is_expected.to contain_file('/etc/apt/sources.list.d/teddybear.list').that_notifies('Exec[apt_update]') }
34 context 'with source' do
35 let(:params) { { :source => 'puppet:///la/die/dah' } }
37 is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]').with({
42 :source => "#{params[:source]}",
46 context 'with content' do
47 let(:params) { default_params }
48 it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]').with({
53 :content => "#{params[:content]}",
58 describe 'settings requiring settings, MODULES-769' do
59 let(:pre_condition) do
61 apt::setting { "list-teddybear": content => "foo" }
64 let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy' } }
65 let(:title) { 'conf-teddybear' }
66 let(:default_params) { { :content => 'di' } }
68 let(:params) { default_params.merge({ :require => 'Apt::Setting[list-teddybear]' }) }
70 it { is_expected.to compile.with_all_deps }
73 describe 'when trying to pull one over' do
74 context 'with source and content' do
75 let(:params) { default_params.merge({ :source => 'la' }) }
77 expect { is_expected.to compile }.to raise_error(Puppet::Error, /cannot have both /)
81 context 'with title=ext-teddybear' do
82 let(:title) { 'ext-teddybear' }
83 let(:params) { default_params }
85 expect { is_expected.to compile }.to raise_error(Puppet::Error, /must start with /)
89 context 'with ensure=banana' do
90 let(:params) { default_params.merge({ :ensure => 'banana' }) }
92 expect { is_expected.to compile }.to raise_error(Puppet::Error, /"banana" does not /)
96 context 'with priority=1.2' do
97 let(:params) { default_params.merge({ :priority => 1.2 }) }
99 expect { is_expected.to compile }.to raise_error(Puppet::Error, /be an integer /)
104 describe 'with priority=100' do
105 let(:params) { default_params.merge({ :priority => 100 }) }
106 it { is_expected.to contain_file('/etc/apt/apt.conf.d/100teddybear').that_notifies('Exec[apt_update]') }
109 describe 'with ensure=absent' do
110 let(:params) { default_params.merge({ :ensure => 'absent' }) }
111 it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]').with({