3 describe 'apt::source', :type => :define do
4 GPG_KEY_ID = '4BD6EC30'
10 context 'mostly defaults' do
13 :lsbdistid => 'Debian',
14 :lsbdistcodename => 'wheezy',
21 'include_deb' => false,
25 it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
26 'ensure' => 'present',
27 'path' => '/etc/apt/sources.list.d/my_source.list',
31 }).with_content(/#file generated by puppet\n# my_source\ndeb-src wheezy main\n/)
35 context 'no defaults' do
38 :lsbdistid => 'Debian',
39 :lsbdistcodename => 'wheezy',
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',
60 it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
61 'ensure' => 'present',
62 'path' => '/etc/apt/sources.list.d/my_source.list',
66 }).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/)
69 it { is_expected.to contain_apt__pin('my_source').that_comes_before('File[my_source.list]').with({
70 'ensure' => 'present',
72 'origin' => 'debian.mirror.iweb.ca',
76 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({
77 'command' => '/usr/bin/apt-get -y install vim',
78 'logoutput' => 'on_failure',
79 'refreshonly' => true,
85 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({
86 'ensure' => 'present',
88 'key_server' => 'pgp.mit.edu',
89 'key_content' => 'GPG key content',
90 'key_source' => 'http://apt.puppetlabs.com/pubkey.gpg',
95 context 'ensure => absent' do
98 :lsbdistid => 'Debian',
99 :lsbdistcodename => 'wheezy',
100 :osfamily => 'Debian'
105 'ensure' => 'absent',
109 it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
115 describe 'validation' do
116 context 'no release' do
119 :lsbdistid => 'Debian',
120 :osfamily => 'Debian'
127 }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/)