3 describe 'apt::source', type: :define do
4 GPG_KEY_ID = '6F6B15509CF8E59E6E469F327F438280EF8D349F'.freeze
10 context 'mostly defaults' do
13 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
15 lsbdistcodename: 'wheezy',
17 puppetversion: Puppet.version,
23 'include' => { 'deb' => false, 'src' => true },
24 'location' => 'http://debian.mirror.iweb.ca/debian/',
29 is_expected.to contain_apt__setting('list-my_source').with_content(/# my_source\ndeb-src http:\/\/debian\.mirror\.iweb\.ca\/debian\/ wheezy main\n/)
33 context 'no defaults' do
36 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
38 lsbdistcodename: 'wheezy',
40 puppetversion: Puppet.version,
46 'location' => 'http://debian.mirror.iweb.ca/debian/',
49 'include' => { 'src' => false },
52 'architecture' => 'x86_64',
53 'allow_unsigned' => true,
58 is_expected.to contain_apt__setting('list-my_source').with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(%r{deb-src}) # rubocop:disable Metrics/LineLength
62 is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with('ensure' => 'present',
64 'origin' => 'debian.mirror.iweb.ca')
68 is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with('ensure' => 'present',
73 context 'allow_unsigned true' do
76 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
78 lsbdistcodename: 'wheezy',
80 puppetversion: Puppet.version,
85 'include' => { 'src' => false },
86 'location' => 'http://debian.mirror.iweb.ca/debian/',
87 'allow_unsigned' => true,
91 it { is_expected.to contain_apt__setting('list-my_source').with_content(/# my_source\ndeb \[trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ wheezy main\n/) }
94 context 'architecture equals x86_64' do
97 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
99 lsbdistcodename: 'wheezy',
101 puppetversion: Puppet.version,
106 'location' => 'http://debian.mirror.iweb.ca/debian/',
107 'architecture' => 'x86_64',
112 is_expected.to contain_apt__setting('list-my_source').with_content(/# my_source\ndeb \[arch=x86_64\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ wheezy main\n/)
116 context 'ensure => absent' do
119 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
121 lsbdistcodename: 'wheezy',
123 puppetversion: Puppet.version,
128 'ensure' => 'absent',
133 is_expected.to contain_apt__setting('list-my_source').with('ensure' => 'absent')
137 describe 'validation' do
138 context 'no release' do
141 os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
144 puppetversion: Puppet.version,
149 expect { subject.call }.to raise_error(Puppet::Error, %r{lsbdistcodename fact not available: release parameter required})