3 describe 'apt::source', :type => :define do
4 GPG_KEY_ID = '6F6B15509CF8E59E6E469F327F438280EF8D349F'
10 context 'mostly defaults' do
13 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
14 :lsbdistid => 'Debian',
15 :lsbdistcodename => 'wheezy',
16 :osfamily => 'Debian',
17 :puppetversion => Puppet.version,
23 'include_deb' => false,
24 'include_src' => true,
25 'location' => 'http://debian.mirror.iweb.ca/debian/',
29 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/)
33 context 'no defaults' do
36 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
37 :lsbdistid => 'Debian',
38 :lsbdistcodename => 'wheezy',
39 :osfamily => 'Debian',
40 :puppetversion => Puppet.version,
46 'location' => 'http://debian.mirror.iweb.ca/debian/',
49 'include_src' => false,
50 'required_packages' => 'vim',
52 'key_server' => 'pgp.mit.edu',
53 'key_content' => 'GPG key content',
54 'key_source' => 'http://apt.puppetlabs.com/pubkey.gpg',
56 'architecture' => 'x86_64',
57 'trusted_source' => true,
61 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/)
64 it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with({
65 'ensure' => 'present',
67 'origin' => 'debian.mirror.iweb.ca',
71 it { is_expected.to contain_exec("Required packages: 'vim' for my_source").that_comes_before('Apt::Setting[list-my_source]').with({
72 'command' => '/usr/bin/apt-get -y install vim',
73 'logoutput' => 'on_failure',
74 'refreshonly' => true,
80 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({
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 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
94 :lsbdistid => 'Debian',
95 :lsbdistcodename => 'wheezy',
96 :osfamily => 'Debian',
97 :puppetversion => Puppet.version,
102 'include_src' => false,
103 'location' => 'http://debian.mirror.iweb.ca/debian/',
104 'trusted_source' => true,
108 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/) }
111 context 'architecture equals x86_64' do
114 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
115 :lsbdistid => 'Debian',
116 :lsbdistcodename => 'wheezy',
117 :osfamily => 'Debian',
118 :puppetversion => Puppet.version,
123 'location' => 'http://debian.mirror.iweb.ca/debian/',
124 'architecture' => 'x86_64',
128 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/)
132 context 'ensure => absent' do
135 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
136 :lsbdistid => 'Debian',
137 :lsbdistcodename => 'wheezy',
138 :osfamily => 'Debian',
139 :puppetversion => Puppet.version,
144 'ensure' => 'absent',
148 it { is_expected.to contain_apt__setting('list-my_source').with({
154 describe 'validation' do
155 context 'no release' do
158 :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
159 :lsbdistid => 'Debian',
160 :osfamily => 'Debian',
161 :puppetversion => Puppet.version,
166 expect { subject.call }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/)