3 describe 'apt::source', :type => :define do
4 GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30'
14 context 'mostly defaults' do
17 :lsbdistid => 'Debian',
18 :lsbdistcodename => 'wheezy',
25 'include_deb' => false,
29 it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
30 'ensure' => 'present',
31 'path' => '/etc/apt/sources.list.d/my_source.list',
35 }).with_content(/# my_source\ndeb-src wheezy main\n/)
39 context 'no defaults' do
42 :lsbdistid => 'Debian',
43 :lsbdistcodename => 'wheezy',
50 'location' => 'http://debian.mirror.iweb.ca/debian/',
53 'include_src' => false,
55 'key_server' => 'pgp.mit.edu',
56 'key_content' => 'GPG key content',
57 'key_source' => 'http://apt.puppetlabs.com/pubkey.gpg',
59 'architecture' => 'x86_64',
60 'trusted_source' => true,
64 it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
65 'ensure' => 'present',
66 'path' => '/etc/apt/sources.list.d/my_source.list',
70 }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/)
73 it { is_expected.to contain_apt__pin('my_source').that_comes_before('File[my_source.list]').with({
74 'ensure' => 'present',
76 'origin' => 'debian.mirror.iweb.ca',
80 it { is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('File[my_source.list]').with({
81 'ensure' => 'present',
83 'key_server' => 'pgp.mit.edu',
84 'key_content' => 'GPG key content',
85 'key_source' => 'http://apt.puppetlabs.com/pubkey.gpg',
90 context 'trusted_source true' do
93 :lsbdistid => 'Debian',
94 :lsbdistcodename => 'wheezy',
100 'include_src' => false,
101 'trusted_source' => true,
105 it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
106 'ensure' => 'present',
107 'path' => '/etc/apt/sources.list.d/my_source.list',
111 }).with_content(/# my_source\ndeb \[trusted=yes\] wheezy main\n/)
115 context 'architecture equals x86_64' do
118 :lsbdistid => 'Debian',
119 :lsbdistcodename => 'wheezy',
120 :osfamily => 'Debian'
125 'include_deb' => false,
126 'architecture' => 'x86_64',
130 it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
131 'ensure' => 'present',
132 'path' => '/etc/apt/sources.list.d/my_source.list',
136 }).with_content(/# my_source\ndeb-src \[arch=x86_64 \] wheezy main\n/)
140 context 'ensure => absent' do
143 :lsbdistid => 'Debian',
144 :lsbdistcodename => 'wheezy',
145 :osfamily => 'Debian'
150 'ensure' => 'absent',
154 it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
160 describe 'validation' do
161 context 'no release' do
164 :lsbdistid => 'Debian',
165 :osfamily => 'Debian'
172 }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/)