1 # frozen_string_literal: true
5 describe 'apt::source', type: :define do
6 GPG_KEY_ID = '6F6B15509CF8E59E6E469F327F438280EF8D349F'.freeze
14 os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
16 lsbdistcodename: 'jessie',
21 context 'with mostly defaults' do
24 'include' => { 'deb' => false, 'src' => true },
25 'location' => 'http://debian.mirror.iweb.ca/debian/',
30 is_expected.to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb-src http://debian.mirror.iweb.ca/debian/ jessie main\n})
34 context 'with no defaults' do
38 'location' => 'http://debian.mirror.iweb.ca/debian/',
41 'include' => { 'src' => false },
44 'architecture' => 'x86_64',
45 'allow_unsigned' => true,
50 is_expected.to contain_apt__setting('list-my_source').with_content(%r{# foo\ndeb \[arch=x86_64 trusted=yes\] http://debian.mirror.iweb.ca/debian/ sid testing\n})
51 .without_content(%r{deb-src})
55 is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with('ensure' => 'present',
57 'origin' => 'debian.mirror.iweb.ca')
61 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',
66 context 'when allow_unsigned true' do
69 'include' => { 'src' => false },
70 'location' => 'http://debian.mirror.iweb.ca/debian/',
71 'allow_unsigned' => true,
75 it { is_expected.to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb \[trusted=yes\] http://debian.mirror.iweb.ca/debian/ jessie main\n}) }
78 context 'with architecture equals x86_64' do
81 'location' => 'http://debian.mirror.iweb.ca/debian/',
82 'architecture' => 'x86_64',
87 is_expected.to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb \[arch=x86_64\] http://debian.mirror.iweb.ca/debian/ jessie main\n})
91 context 'with ensure => absent' do
99 is_expected.to contain_apt__setting('list-my_source').with('ensure' => 'absent')
103 describe 'validation' do
104 context 'with no release' do
107 os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
113 is_expected.to raise_error(Puppet::Error, %r{lsbdistcodename fact not available: release parameter required})