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
12 os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
15 lsbdistcodename: 'jessie',
20 is_expected.to contain_apt__source('backports').with(location: 'http://deb.debian.org/debian',
21 repos: 'main contrib non-free',
22 release: 'jessie-backports',
23 pin: { 'priority' => 200, 'release' => 'jessie-backports' })
26 context 'with defaults on ubuntu' do
29 os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } },
32 lsbdistcodename: 'xenial',
33 lsbdistrelease: '16.04',
38 is_expected.to contain_apt__source('backports').with(location: 'http://archive.ubuntu.com/ubuntu',
39 key: '630239CC130E1A7FD81A27B140976EAF437D05B5',
40 repos: 'main universe multiverse restricted',
41 release: 'xenial-backports',
42 pin: { 'priority' => 200, 'release' => 'xenial-backports' })
45 context 'with everything set' do
48 os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } },
51 lsbdistcodename: 'xenial',
52 lsbdistrelease: '16.04',
57 location: 'http://archive.ubuntu.com/ubuntu-test',
60 key: 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553',
66 is_expected.to contain_apt__source('backports').with(location: 'http://archive.ubuntu.com/ubuntu-test',
67 key: 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553',
70 pin: { 'priority' => 90, 'release' => 'vivid' })
73 context 'when set things with hashes' do
76 os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } },
79 lsbdistcodename: 'xenial',
80 lsbdistrelease: '16.04',
86 'id' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553',
95 is_expected.to contain_apt__source('backports').with(key: { 'id' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553' },
96 pin: { 'priority' => '90' })
100 describe 'mint tests' do
103 os: { family: 'Debian', name: 'Linuxmint', release: { major: '17', full: '17' } },
104 lsbdistid: 'linuxmint',
106 lsbdistcodename: 'qiana',
110 context 'with all the needed things set' do
113 location: 'http://archive.ubuntu.com/ubuntu',
114 release: 'trusty-backports',
115 repos: 'main universe multiverse restricted',
116 key: '630239CC130E1A7FD81A27B140976EAF437D05B5',
121 is_expected.to contain_apt__source('backports').with(location: 'http://archive.ubuntu.com/ubuntu',
122 key: '630239CC130E1A7FD81A27B140976EAF437D05B5',
123 repos: 'main universe multiverse restricted',
124 release: 'trusty-backports',
125 pin: { 'priority' => 200, 'release' => 'trusty-backports' })
128 context 'with missing location' do
131 release: 'trusty-backports',
132 repos: 'main universe multiverse restricted',
133 key: '630239CC130E1A7FD81A27B140976EAF437D05B5',
138 is_expected.to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key})
141 context 'with missing release' do
144 location: 'http://archive.ubuntu.com/ubuntu',
145 repos: 'main universe multiverse restricted',
146 key: '630239CC130E1A7FD81A27B140976EAF437D05B5',
151 is_expected.to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key})
154 context 'with missing repos' do
157 location: 'http://archive.ubuntu.com/ubuntu',
158 release: 'trusty-backports',
159 key: '630239CC130E1A7FD81A27B140976EAF437D05B5',
164 is_expected.to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key})
167 context 'with missing key' do
170 location: 'http://archive.ubuntu.com/ubuntu',
171 release: 'trusty-backports',
172 repos: 'main universe multiverse restricted',
177 is_expected.to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key})
181 describe 'validation' do
184 os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } },
187 lsbdistcodename: 'xenial',
188 lsbdistrelease: '16.04',
192 context 'with invalid location' do
200 is_expected.to raise_error(Puppet::Error, %r{expects a})
203 context 'with invalid release' do
211 is_expected.to raise_error(Puppet::Error, %r{expects a})
214 context 'with invalid repos' do
222 is_expected.to raise_error(Puppet::Error, %r{expects a})
225 context 'with invalid key' do
233 is_expected.to raise_error(Puppet::Error, %r{expects a})
236 context 'with invalid pin' do
244 is_expected.to raise_error(Puppet::Error, %r{expects a})