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,
26 'include_src' => true,
30 it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
31 'ensure' => 'present',
32 'path' => '/etc/apt/sources.list.d/my_source.list',
36 }).with_content(/# my_source\ndeb-src wheezy main\n/)
40 context 'no defaults' do
43 :lsbdistid => 'Debian',
44 :lsbdistcodename => 'wheezy',
51 'location' => 'http://debian.mirror.iweb.ca/debian/',
54 'include_src' => false,
56 'key_server' => 'pgp.mit.edu',
57 'key_content' => 'GPG key content',
58 'key_source' => 'http://apt.puppetlabs.com/pubkey.gpg',
60 'architecture' => 'x86_64',
61 'trusted_source' => true,
65 it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
66 'ensure' => 'present',
67 'path' => '/etc/apt/sources.list.d/my_source.list',
71 }).with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/)
74 it { is_expected.to contain_apt__pin('my_source').that_comes_before('File[my_source.list]').with({
75 'ensure' => 'present',
77 'origin' => 'debian.mirror.iweb.ca',
81 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({
82 'ensure' => 'present',
84 'key_server' => 'pgp.mit.edu',
85 'key_content' => 'GPG key content',
86 'key_source' => 'http://apt.puppetlabs.com/pubkey.gpg',
91 context 'trusted_source true' do
94 :lsbdistid => 'Debian',
95 :lsbdistcodename => 'wheezy',
101 'include_src' => false,
102 'trusted_source' => true,
106 it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
107 'ensure' => 'present',
108 'path' => '/etc/apt/sources.list.d/my_source.list',
112 }).with_content(/# my_source\ndeb \[trusted=yes\] wheezy main\n/)
116 context 'architecture equals x86_64' do
119 :lsbdistid => 'Debian',
120 :lsbdistcodename => 'wheezy',
121 :osfamily => 'Debian'
126 'include_deb' => false,
127 'include_src' => true,
128 'architecture' => 'x86_64',
132 it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
133 'ensure' => 'present',
134 'path' => '/etc/apt/sources.list.d/my_source.list',
138 }).with_content(/# my_source\ndeb-src \[arch=x86_64 \] wheezy main\n/)
142 context 'ensure => absent' do
145 :lsbdistid => 'Debian',
146 :lsbdistcodename => 'wheezy',
147 :osfamily => 'Debian'
152 'ensure' => 'absent',
156 it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
162 describe 'validation' do
163 context 'no release' do
166 :lsbdistid => 'Debian',
167 :osfamily => 'Debian'
174 }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/)