3 describe 'apt::source', :type => :define do
4 GPG_KEY_ID = '4BD6EC30'
10 context 'mostly defaults' do
13 :lsbdistid => 'Debian',
14 :lsbdistcodename => 'wheezy',
20 'include_deb' => false,
24 it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
25 'ensure' => 'present',
26 'path' => '/etc/apt/sources.list.d/my_source.list',
30 }).with_content(/#file generated by puppet\n# my_source\ndeb-src wheezy main\n/)
34 context 'no defaults' do
37 :lsbdistid => 'Debian',
38 :lsbdistcodename => 'wheezy',
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',
58 it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
59 'ensure' => 'present',
60 'path' => '/etc/apt/sources.list.d/my_source.list',
64 }).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/)
67 it { is_expected.to contain_apt__pin('my_source').that_comes_before('File[my_source.list]').with({
68 'ensure' => 'present',
70 'origin' => 'debian.mirror.iweb.ca',
74 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({
75 'command' => '/usr/bin/apt-get -y install vim',
76 'logoutput' => 'on_failure',
77 'refreshonly' => true,
83 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({
84 'ensure' => 'present',
86 'key_server' => 'pgp.mit.edu',
87 'key_content' => 'GPG key content',
88 'key_source' => 'http://apt.puppetlabs.com/pubkey.gpg',
93 context 'ensure => absent' do
96 :lsbdistid => 'Debian',
97 :lsbdistcodename => 'wheezy',
102 'ensure' => 'absent',
106 it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
112 describe 'validation' do
113 context 'no release' do
116 :lsbdistid => 'Debian',
123 }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/)