1 # frozen_string_literal: true
5 describe 'apt::backports', type: :class do
6 let(:pre_condition) { "class{ '::apt': }" }
8 describe 'debian/ubuntu tests' do
9 context 'with defaults on deb' do
28 expect(subject).to contain_apt__source('backports').with(location: 'http://deb.debian.org/debian',
29 repos: 'main contrib non-free',
30 release: 'stretch-backports',
31 pin: { 'priority' => 200, 'release' => 'stretch-backports' })
35 context 'with defaults on ubuntu' do
54 expect(subject).to contain_apt__source('backports').with(location: 'http://archive.ubuntu.com/ubuntu',
55 key: '630239CC130E1A7FD81A27B140976EAF437D05B5',
56 repos: 'main universe multiverse restricted',
57 release: 'bionac-backports',
58 pin: { 'priority' => 200, 'release' => 'bionac-backports' })
62 context 'with everything set' do
81 location: 'http://archive.ubuntu.com/ubuntu-test',
84 key: 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553',
90 expect(subject).to contain_apt__source('backports').with(location: 'http://archive.ubuntu.com/ubuntu-test',
91 key: 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553',
94 pin: { 'priority' => 90, 'release' => 'vivid' })
98 context 'when set things with hashes' do
118 'id' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553',
127 expect(subject).to contain_apt__source('backports').with(key: { 'id' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553' },
128 pin: { 'priority' => '90' })
133 describe 'mint tests' do
151 context 'with all the needed things set' do
154 location: 'http://archive.ubuntu.com/ubuntu',
155 release: 'trusty-backports',
156 repos: 'main universe multiverse restricted',
157 key: '630239CC130E1A7FD81A27B140976EAF437D05B5',
162 expect(subject).to contain_apt__source('backports').with(location: 'http://archive.ubuntu.com/ubuntu',
163 key: '630239CC130E1A7FD81A27B140976EAF437D05B5',
164 repos: 'main universe multiverse restricted',
165 release: 'trusty-backports',
166 pin: { 'priority' => 200, 'release' => 'trusty-backports' })
170 context 'with missing location' do
173 release: 'trusty-backports',
174 repos: 'main universe multiverse restricted',
175 key: '630239CC130E1A7FD81A27B140976EAF437D05B5',
180 expect(subject).to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key})
184 context 'with missing release' do
187 location: 'http://archive.ubuntu.com/ubuntu',
188 repos: 'main universe multiverse restricted',
189 key: '630239CC130E1A7FD81A27B140976EAF437D05B5',
194 expect(subject).to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key})
198 context 'with missing repos' do
201 location: 'http://archive.ubuntu.com/ubuntu',
202 release: 'trusty-backports',
203 key: '630239CC130E1A7FD81A27B140976EAF437D05B5',
208 expect(subject).to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key})
212 context 'with missing key' do
215 location: 'http://archive.ubuntu.com/ubuntu',
216 release: 'trusty-backports',
217 repos: 'main universe multiverse restricted',
222 expect(subject).to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key})
227 describe 'validation' do
245 context 'with invalid location' do
253 expect(subject).to raise_error(Puppet::Error, %r{expects a})
257 context 'with invalid release' do
265 expect(subject).to raise_error(Puppet::Error, %r{expects a})
269 context 'with invalid repos' do
277 expect(subject).to raise_error(Puppet::Error, %r{expects a})
281 context 'with invalid key' do
289 expect(subject).to raise_error(Puppet::Error, %r{expects a})
293 context 'with invalid pin' do
301 expect(subject).to raise_error(Puppet::Error, %r{expects a})