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',
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 trusted=yes\] 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 'trusted true' do
99 :lsbdistid => 'Debian',
100 :lsbdistcodename => 'wheezy',
101 :osfamily => 'Debian'
106 'include_src' => false,
111 it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
112 'ensure' => 'present',
113 'path' => '/etc/apt/sources.list.d/my_source.list',
117 }).with_content(/#file generated by puppet\n# my_source\ndeb \[trusted=yes\] wheezy main\n/)
121 context 'architecture equals x86_64' do
124 :lsbdistid => 'Debian',
125 :lsbdistcodename => 'wheezy',
126 :osfamily => 'Debian'
131 'include_deb' => false,
132 'architecture' => 'x86_64',
136 it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
137 'ensure' => 'present',
138 'path' => '/etc/apt/sources.list.d/my_source.list',
142 }).with_content(/#file generated by puppet\n# my_source\ndeb-src \[arch=x86_64 \] wheezy main\n/)
146 context 'ensure => absent' do
149 :lsbdistid => 'Debian',
150 :lsbdistcodename => 'wheezy',
151 :osfamily => 'Debian'
156 'ensure' => 'absent',
160 it { is_expected.to contain_file('my_source.list').that_notifies('Exec[apt_update]').with({
166 describe 'validation' do
167 context 'no release' do
170 :lsbdistid => 'Debian',
171 :osfamily => 'Debian'
178 }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/)