3 describe 'apt::setting' do
4 let(:pre_condition) { 'class { "apt": }' }
5 let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
6 let(:title) { 'teddybear' }
8 let(:default_params) { { :setting_type => 'conf', :content => 'di' } }
10 describe 'when using the defaults' do
11 context 'without setting_type' do
13 expect { is_expected.to compile }.to raise_error(Puppet::Error, /Must pass setting_type /)
17 context 'without source or content' do
18 let(:params) { { :setting_type => 'conf' } }
20 expect { is_expected.to compile }.to raise_error(Puppet::Error, /needs either of /)
24 context 'with setting_type=conf' do
25 let(:params) { default_params }
26 it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear') }
29 context 'with setting_type=pref' do
30 let(:params) { { :setting_type => 'pref', :content => 'di' } }
31 it { is_expected.to contain_file('/etc/apt/preferences.d/50teddybear') }
34 context 'with setting_type=list' do
35 let(:params) { { :setting_type => 'list', :content => 'di' } }
36 it { is_expected.to contain_file('/etc/apt/sources.list.d/teddybear.list') }
39 context 'with source' do
40 let(:params) { { :setting_type => 'conf', :source => 'puppet:///la/die/dah' } }
42 is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').with({
47 :source => "#{params[:source]}",
51 context 'with content' do
52 let(:params) { default_params }
53 it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').with({
58 :content => "#{params[:content]}",
63 describe 'when trying to pull one over' do
64 context 'with source and content' do
65 let(:params) { default_params.merge({ :source => 'la' }) }
67 expect { is_expected.to compile }.to raise_error(Puppet::Error, /cannot have both /)
71 context 'with setting_type=ext' do
72 let(:params) { default_params.merge({ :setting_type => 'ext' }) }
74 expect { is_expected.to compile }.to raise_error(Puppet::Error, /"ext" does not /)
78 context 'with ensure=banana' do
79 let(:params) { default_params.merge({ :ensure => 'banana' }) }
81 expect { is_expected.to compile }.to raise_error(Puppet::Error, /"banana" does not /)
85 context 'with priority=1.2' do
86 let(:params) { default_params.merge({ :priority => 1.2 }) }
88 expect { is_expected.to compile }.to raise_error(Puppet::Error, /be an integer /)
93 describe 'with priority=100' do
94 let(:params) { default_params.merge({ :priority => 100 }) }
95 it { is_expected.to contain_file('/etc/apt/apt.conf.d/100teddybear') }
98 describe 'with base_name=puppy' do
99 let(:params) { default_params.merge({ :base_name => 'puppy' }) }
100 it { should contain_file('/etc/apt/apt.conf.d/50puppy') }
103 describe 'with base_name=true' do
104 let(:params) { default_params.merge({ :base_name => true }) }
106 expect { should compile }.to raise_error(Puppet::Error, /not a string/)
110 describe 'with ensure=absent' do
111 let(:params) { default_params.merge({ :ensure => 'absent' }) }
112 it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').with({
117 describe 'with file_perms' do
118 context "{'owner' => 'roosevelt'}" do
119 let(:params) { default_params.merge({ :file_perms => {'owner' => 'roosevelt'} }) }
120 it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').with({
121 :owner => 'roosevelt',
127 context "'group' => 'roosevelt'}" do
128 let(:params) { default_params.merge({ :file_perms => {'group' => 'roosevelt'} }) }
129 it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').with({
131 :group => 'roosevelt',
136 context "'owner' => 'roosevelt'}" do
137 let(:params) { default_params.merge({ :file_perms => {'mode' => '0600'} }) }
138 it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').with({