3 describe 'apt::source', :type => :define do
4 GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30'
10 context 'mostly defaults' do
13 :lsbdistid => 'Debian',
14 :lsbdistcodename => 'wheezy',
15 :osfamily => 'Debian',
21 'include_deb' => false,
22 'include_src' => true,
23 'location' => 'http://debian.mirror.iweb.ca/debian/',
27 it { is_expected.to contain_apt__setting('list-my_source').with_content(/# my_source\ndeb-src http:\/\/debian\.mirror\.iweb\.ca\/debian\/ wheezy main\n/)
31 context 'no defaults' do
34 :lsbdistid => 'Debian',
35 :lsbdistcodename => 'wheezy',
42 'location' => 'http://debian.mirror.iweb.ca/debian/',
45 'include_src' => false,
46 'required_packages' => 'vim',
48 'key_server' => 'pgp.mit.edu',
49 'key_content' => 'GPG key content',
50 'key_source' => 'http://apt.puppetlabs.com/pubkey.gpg',
52 'architecture' => 'x86_64',
53 'trusted_source' => true,
57 it { is_expected.to contain_apt__setting('list-my_source').with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/)
60 it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({
61 'ensure' => 'present',
63 'origin' => 'debian.mirror.iweb.ca',
67 it { is_expected.to contain_exec("Required packages: 'vim' for my_source").that_comes_before('Apt::Setting[list-my_source]').with({
68 'command' => '/usr/bin/apt-get -y install vim',
69 'logoutput' => 'on_failure',
70 'refreshonly' => true,
76 it { 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({
77 'ensure' => 'present',
79 'key_server' => 'pgp.mit.edu',
80 'key_content' => 'GPG key content',
81 'key_source' => 'http://apt.puppetlabs.com/pubkey.gpg',
86 context 'trusted_source true' do
89 :lsbdistid => 'Debian',
90 :lsbdistcodename => 'wheezy',
96 'include_src' => false,
97 'location' => 'http://debian.mirror.iweb.ca/debian/',
98 'trusted_source' => true,
102 it { is_expected.to contain_apt__setting('list-my_source').with_content(/# my_source\ndeb \[trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ wheezy main\n/) }
105 context 'architecture equals x86_64' do
108 :lsbdistid => 'Debian',
109 :lsbdistcodename => 'wheezy',
110 :osfamily => 'Debian'
115 'location' => 'http://debian.mirror.iweb.ca/debian/',
116 'architecture' => 'x86_64',
120 it { is_expected.to contain_apt__setting('list-my_source').with_content(/# my_source\ndeb \[arch=x86_64\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ wheezy main\n/)
124 context 'ensure => absent' do
127 :lsbdistid => 'Debian',
128 :lsbdistcodename => 'wheezy',
129 :osfamily => 'Debian'
134 'ensure' => 'absent',
138 it { is_expected.to contain_apt__setting('list-my_source').with({
144 describe 'validation' do
145 context 'no release' do
148 :lsbdistid => 'Debian',
149 :osfamily => 'Debian'
154 expect { subject.call }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/)