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 is_expected.to contain_apt__source('backports').with(location: 'http://deb.debian.org/debian',
29 repos: 'main contrib non-free',
30 release: 'jessie-backports',
31 pin: { 'priority' => 200, 'release' => 'jessie-backports' })
34 context 'with defaults on ubuntu' do
53 is_expected.to contain_apt__source('backports').with(location: 'http://archive.ubuntu.com/ubuntu',
54 key: '630239CC130E1A7FD81A27B140976EAF437D05B5',
55 repos: 'main universe multiverse restricted',
56 release: 'xenial-backports',
57 pin: { 'priority' => 200, 'release' => 'xenial-backports' })
60 context 'with everything set' do
79 location: 'http://archive.ubuntu.com/ubuntu-test',
82 key: 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553',
88 is_expected.to contain_apt__source('backports').with(location: 'http://archive.ubuntu.com/ubuntu-test',
89 key: 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553',
92 pin: { 'priority' => 90, 'release' => 'vivid' })
95 context 'when set things with hashes' do
115 'id' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553',
124 is_expected.to contain_apt__source('backports').with(key: { 'id' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553' },
125 pin: { 'priority' => '90' })
129 describe 'mint tests' do
147 context 'with all the needed things set' do
150 location: 'http://archive.ubuntu.com/ubuntu',
151 release: 'trusty-backports',
152 repos: 'main universe multiverse restricted',
153 key: '630239CC130E1A7FD81A27B140976EAF437D05B5',
158 is_expected.to contain_apt__source('backports').with(location: 'http://archive.ubuntu.com/ubuntu',
159 key: '630239CC130E1A7FD81A27B140976EAF437D05B5',
160 repos: 'main universe multiverse restricted',
161 release: 'trusty-backports',
162 pin: { 'priority' => 200, 'release' => 'trusty-backports' })
165 context 'with missing location' do
168 release: 'trusty-backports',
169 repos: 'main universe multiverse restricted',
170 key: '630239CC130E1A7FD81A27B140976EAF437D05B5',
175 is_expected.to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key})
178 context 'with missing release' do
181 location: 'http://archive.ubuntu.com/ubuntu',
182 repos: 'main universe multiverse restricted',
183 key: '630239CC130E1A7FD81A27B140976EAF437D05B5',
188 is_expected.to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key})
191 context 'with missing repos' do
194 location: 'http://archive.ubuntu.com/ubuntu',
195 release: 'trusty-backports',
196 key: '630239CC130E1A7FD81A27B140976EAF437D05B5',
201 is_expected.to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key})
204 context 'with missing key' do
207 location: 'http://archive.ubuntu.com/ubuntu',
208 release: 'trusty-backports',
209 repos: 'main universe multiverse restricted',
214 is_expected.to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key})
218 describe 'validation' do
236 context 'with invalid location' do
244 is_expected.to raise_error(Puppet::Error, %r{expects a})
247 context 'with invalid release' do
255 is_expected.to raise_error(Puppet::Error, %r{expects a})
258 context 'with invalid repos' do
266 is_expected.to raise_error(Puppet::Error, %r{expects a})
269 context 'with invalid key' do
277 is_expected.to raise_error(Puppet::Error, %r{expects a})
280 context 'with invalid pin' do
288 is_expected.to raise_error(Puppet::Error, %r{expects a})