1 # frozen_string_literal: true
5 describe 'apt::source', type: :define do
6 GPG_KEY_ID = '6F6B15509CF8E59E6E469F327F438280EF8D349F'
29 context 'with mostly defaults' do
32 'include' => { 'deb' => false, 'src' => true },
33 'location' => 'http://debian.mirror.iweb.ca/debian/',
38 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})
42 context 'with no defaults' do
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(%r{# foo\ndeb \[arch=x86_64 trusted=yes\] http://debian.mirror.iweb.ca/debian/ sid testing\n})
59 .without_content(%r{deb-src})
63 is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with('ensure' => 'present',
65 'origin' => 'debian.mirror.iweb.ca')
69 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',
74 context 'when allow_unsigned true' do
77 'include' => { 'src' => false },
78 'location' => 'http://debian.mirror.iweb.ca/debian/',
79 'allow_unsigned' => true,
83 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}) }
86 context 'with architecture equals x86_64' do
89 'location' => 'http://debian.mirror.iweb.ca/debian/',
90 'architecture' => 'x86_64',
95 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})
99 context 'with ensure => absent' do
102 'ensure' => 'absent',
107 is_expected.to contain_apt__setting('list-my_source').with('ensure' => 'absent')
111 describe 'validation' do
112 context 'with no release' do
130 is_expected.to raise_error(Puppet::Error, %r{os.distro.codename fact not available: release parameter required})