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' } },
9 lsbdistcodename: 'wheezy',
10 operatingsystem: '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, %r{needs either of })
27 context 'with title=conf-teddybear ' do
28 let(:params) { default_params }
30 it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]') }
33 context 'with title=pref-teddybear' do
34 let(:title) { 'pref-teddybear' }
35 let(:params) { default_params }
37 it { is_expected.to contain_file('/etc/apt/preferences.d/teddybear.pref').that_notifies('Class[Apt::Update]') }
40 context 'with title=list-teddybear' do
41 let(:title) { 'list-teddybear' }
42 let(:params) { default_params }
44 it { is_expected.to contain_file('/etc/apt/sources.list.d/teddybear.list').that_notifies('Class[Apt::Update]') }
47 context 'with source' do
48 let(:params) { { source: 'puppet:///la/die/dah' } }
51 is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with(ensure: 'file',
55 source: params[:source].to_s)
59 context 'with content' do
60 let(:params) { default_params }
63 is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with(ensure: 'file',
67 content: params[:content].to_s)
72 describe 'settings requiring settings, MODULES-769' do
73 let(:pre_condition) do
75 apt::setting { "list-teddybear": content => "foo" }
80 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
83 lsbdistcodename: 'wheezy',
84 puppetversion: Puppet.version,
87 let(:title) { 'conf-teddybear' }
88 let(:default_params) { { content: 'di' } }
90 let(:params) { default_params.merge(require: 'Apt::Setting[list-teddybear]') }
92 it { is_expected.to compile.with_all_deps }
95 describe 'when trying to pull one over' do
96 context 'with source and content' do
97 let(:params) { default_params.merge(source: 'la') }
100 expect { subject.call }.to raise_error(Puppet::Error, %r{cannot have both })
104 context 'with title=ext-teddybear' do
105 let(:title) { 'ext-teddybear' }
106 let(:params) { default_params }
109 expect { subject.call }.to raise_error(Puppet::Error, %r{must start with either})
113 context 'with ensure=banana' do
114 let(:params) { default_params.merge(ensure: 'banana') }
117 expect { subject.call }.to raise_error(Puppet::Error, %r{Enum\['absent', 'file', 'present'\]})
121 context 'with priority=1.2' do
122 let(:params) { default_params.merge(priority: 1.2) }
124 if Puppet::Util::Package.versioncmp(Puppet.version, '4.0') >= 0 || ENV['FUTURE_PARSER'] == 'yes'
125 it { is_expected.to compile.and_raise_error(%r{expects a value of type}) }
127 it { is_expected.to compile.and_raise_error(%r{priority must be an integer or a zero-padded integer}) }
132 describe 'with priority=100' do
133 let(:params) { default_params.merge(priority: 100) }
135 it { is_expected.to contain_file('/etc/apt/apt.conf.d/100teddybear').that_notifies('Class[Apt::Update]') }
138 describe 'with ensure=absent' do
139 let(:params) { default_params.merge(ensure: 'absent') }
142 is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with(ensure: 'absent')