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,
54 'required_packages' => 'vim',
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_exec("Required packages: 'vim' for my_source").that_comes_before('Exec[apt_update]').that_subscribes_to('File[my_source.list]').with({
82 'command' => '/usr/bin/apt-get -y install vim',
83 'logoutput' => 'on_failure',
84 'refreshonly' => true,
90 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({
91 'ensure' => 'present',
93 'key_server' => 'pgp.mit.edu',
94 'key_content' => 'GPG key content',
95 'key_source' => 'http://apt.puppetlabs.com/pubkey.gpg',
100 context 'trusted_source true' do
103 :lsbdistid => 'Debian',
104 :lsbdistcodename => 'wheezy',
105 :osfamily => 'Debian'
110 'include_src' => false,
111 'trusted_source' => true,
115 it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
116 'ensure' => 'present',
117 'path' => '/etc/apt/sources.list.d/my_source.list',
121 }).with_content(/# my_source\ndeb \[trusted=yes\] wheezy main\n/)
125 context 'architecture equals x86_64' do
128 :lsbdistid => 'Debian',
129 :lsbdistcodename => 'wheezy',
130 :osfamily => 'Debian'
135 'include_deb' => false,
136 'architecture' => 'x86_64',
140 it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
141 'ensure' => 'present',
142 'path' => '/etc/apt/sources.list.d/my_source.list',
146 }).with_content(/# my_source\ndeb-src \[arch=x86_64 \] wheezy main\n/)
150 context 'ensure => absent' do
153 :lsbdistid => 'Debian',
154 :lsbdistcodename => 'wheezy',
155 :osfamily => 'Debian'
160 'ensure' => 'absent',
164 it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
170 describe 'validation' do
171 context 'no release' do
174 :lsbdistid => 'Debian',
175 :osfamily => 'Debian'
182 }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/)