1 # frozen_string_literal: true
5 describe 'apt::source', type: :define do
6 let(:id) { '6F6B15509CF8E59E6E469F327F438280EF8D349F' }
7 let(:title) { 'my_source' }
25 context 'with mostly defaults' do
28 'include' => { 'deb' => false, 'src' => true },
29 'location' => 'http://debian.mirror.iweb.ca/debian/'
34 expect(subject).to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb-src http://debian.mirror.iweb.ca/debian/ stretch main\n})
38 context 'with no defaults' do
42 'location' => 'http://debian.mirror.iweb.ca/debian/',
45 'include' => { 'src' => false },
48 'architecture' => 'x86_64',
49 'allow_unsigned' => true
54 expect(subject).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})
55 .without_content(%r{deb-src})
59 expect(subject).to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with('ensure' => 'present',
61 'origin' => 'debian.mirror.iweb.ca')
65 expect(subject).to contain_apt__key("Add key: #{id} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with('ensure' => 'present',
70 context 'when allow_insecure true' do
73 'include' => { 'src' => false },
74 'location' => 'http://debian.mirror.iweb.ca/debian/',
75 'allow_insecure' => true
79 it { is_expected.to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb \[allow-insecure=yes\] http://debian.mirror.iweb.ca/debian/ stretch main\n}) }
82 context 'when allow_unsigned true' do
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(%r{# my_source\ndeb \[trusted=yes\] http://debian.mirror.iweb.ca/debian/ stretch main\n}) }
94 context 'with architecture equals x86_64' do
97 'location' => 'http://debian.mirror.iweb.ca/debian/',
98 'architecture' => 'x86_64'
103 expect(subject).to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb \[arch=x86_64\] http://debian.mirror.iweb.ca/debian/ stretch main\n})
107 context 'with ensure => absent' do
115 expect(subject).to contain_apt__setting('list-my_source').with('ensure' => 'absent')
119 describe 'validation' do
120 context 'with no release' do
138 expect(subject).to raise_error(Puppet::Error, %r{os.distro.codename fact not available: release parameter required})