3 describe 'apt::source', :type => :define do
4 GPG_KEY_ID = '6F6B15509CF8E59E6E469F327F438280EF8D349F'
10 context 'mostly defaults' do
13 :lsbdistid => 'Debian',
14 :lsbdistcodename => 'wheezy',
15 :osfamily => 'Debian',
16 :puppetversion => Puppet.version,
22 'include_deb' => false,
23 'include_src' => true,
24 'location' => 'http://debian.mirror.iweb.ca/debian/',
28 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/)
32 context 'no defaults' do
35 :lsbdistid => 'Debian',
36 :lsbdistcodename => 'wheezy',
37 :osfamily => 'Debian',
38 :puppetversion => Puppet.version,
44 'location' => 'http://debian.mirror.iweb.ca/debian/',
47 'include_src' => false,
48 'required_packages' => 'vim',
50 'key_server' => 'pgp.mit.edu',
51 'key_content' => 'GPG key content',
52 'key_source' => 'http://apt.puppetlabs.com/pubkey.gpg',
54 'architecture' => 'x86_64',
55 'trusted_source' => true,
59 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/)
62 it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({
63 'ensure' => 'present',
65 'origin' => 'debian.mirror.iweb.ca',
69 it { is_expected.to contain_exec("Required packages: 'vim' for my_source").that_comes_before('Apt::Setting[list-my_source]').with({
70 'command' => '/usr/bin/apt-get -y install vim',
71 'logoutput' => 'on_failure',
72 'refreshonly' => true,
78 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({
79 'ensure' => 'present',
81 'key_server' => 'pgp.mit.edu',
82 'key_content' => 'GPG key content',
83 'key_source' => 'http://apt.puppetlabs.com/pubkey.gpg',
88 context 'trusted_source true' do
91 :lsbdistid => 'Debian',
92 :lsbdistcodename => 'wheezy',
93 :osfamily => 'Debian',
94 :puppetversion => Puppet.version,
99 'include_src' => false,
100 'location' => 'http://debian.mirror.iweb.ca/debian/',
101 'trusted_source' => true,
105 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/) }
108 context 'architecture equals x86_64' do
111 :lsbdistid => 'Debian',
112 :lsbdistcodename => 'wheezy',
113 :osfamily => 'Debian',
114 :puppetversion => Puppet.version,
119 'location' => 'http://debian.mirror.iweb.ca/debian/',
120 'architecture' => 'x86_64',
124 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/)
128 context 'ensure => absent' do
131 :lsbdistid => 'Debian',
132 :lsbdistcodename => 'wheezy',
133 :osfamily => 'Debian',
134 :puppetversion => Puppet.version,
139 'ensure' => 'absent',
143 it { is_expected.to contain_apt__setting('list-my_source').with({
149 describe 'validation' do
150 context 'no release' do
153 :lsbdistid => 'Debian',
154 :osfamily => 'Debian',
155 :puppetversion => Puppet.version,
160 expect { subject.call }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/)