3 describe 'apt::source', :type => :define do
4 GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30'
11 context 'mostly defaults' do
14 :lsbdistid => 'Debian',
15 :lsbdistcodename => 'wheezy',
22 'include_deb' => false,
26 it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
27 'ensure' => 'present',
28 'path' => '/etc/apt/sources.list.d/my_source.list',
32 }).with_content(/#file generated by puppet\n# my_source\ndeb-src wheezy main\n/)
36 context 'no defaults' do
39 :lsbdistid => 'Debian',
40 :lsbdistcodename => 'wheezy',
47 'location' => 'http://debian.mirror.iweb.ca/debian/',
50 'include_src' => false,
51 'required_packages' => 'vim',
53 'key_server' => 'pgp.mit.edu',
54 'key_content' => 'GPG key content',
55 'key_source' => 'http://apt.puppetlabs.com/pubkey.gpg',
57 'architecture' => 'x86_64',
61 it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
62 'ensure' => 'present',
63 'path' => '/etc/apt/sources.list.d/my_source.list',
67 }).with_content(/#file generated by puppet\n# foo\ndeb \[arch=x86_64\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(/deb-src/)
70 it { is_expected.to contain_apt__pin('my_source').that_comes_before('File[my_source.list]').with({
71 'ensure' => 'present',
73 'origin' => 'debian.mirror.iweb.ca',
77 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({
78 'command' => '/usr/bin/apt-get -y install vim',
79 'logoutput' => 'on_failure',
80 'refreshonly' => true,
86 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({
87 'ensure' => 'present',
89 'key_server' => 'pgp.mit.edu',
90 'key_content' => 'GPG key content',
91 'key_source' => 'http://apt.puppetlabs.com/pubkey.gpg',
96 context 'ensure => absent' do
99 :lsbdistid => 'Debian',
100 :lsbdistcodename => 'wheezy',
101 :osfamily => 'Debian'
106 'ensure' => 'absent',
110 it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
116 describe 'validation' do
117 context 'no release' do
120 :lsbdistid => 'Debian',
121 :osfamily => 'Debian'
128 }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/)