3 describe 'apt::setting' do
4 let(:pre_condition) { 'class { "apt": }' }
5 let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
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 'when trying to pull one over' do
59 context 'with source and content' do
60 let(:params) { default_params.merge({ :source => 'la' }) }
62 expect { is_expected.to compile }.to raise_error(Puppet::Error, /cannot have both /)
66 context 'with title=ext-teddybear' do
67 let(:title) { 'ext-teddybear' }
68 let(:params) { default_params }
70 expect { is_expected.to compile }.to raise_error(Puppet::Error, /must start with /)
74 context 'with ensure=banana' do
75 let(:params) { default_params.merge({ :ensure => 'banana' }) }
77 expect { is_expected.to compile }.to raise_error(Puppet::Error, /"banana" does not /)
81 context 'with priority=1.2' do
82 let(:params) { default_params.merge({ :priority => 1.2 }) }
84 expect { is_expected.to compile }.to raise_error(Puppet::Error, /be an integer /)
89 describe 'with priority=100' do
90 let(:params) { default_params.merge({ :priority => 100 }) }
91 it { is_expected.to contain_file('/etc/apt/apt.conf.d/100teddybear').that_notifies('Exec[apt_update]') }
94 describe 'with ensure=absent' do
95 let(:params) { default_params.merge({ :ensure => 'absent' }) }
96 it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]').with({
101 describe 'with file_perms' do
102 context "{'owner' => 'roosevelt'}" do
103 let(:params) { default_params.merge({ :file_perms => {'owner' => 'roosevelt'} }) }
104 it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]').with({
105 :owner => 'roosevelt',
111 context "'group' => 'roosevelt'}" do
112 let(:params) { default_params.merge({ :file_perms => {'group' => 'roosevelt'} }) }
113 it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]').with({
115 :group => 'roosevelt',
120 context "'owner' => 'roosevelt'}" do
121 let(:params) { default_params.merge({ :file_perms => {'mode' => '0600'} }) }
122 it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]').with({
129 context "'notify_update' => false}" do
130 let(:params) { default_params.merge({ :notify_update => false }) }
131 it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear') }
132 it { is_expected.not_to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Exec[apt_update]') }