Merge pull request #815 from simondeziel/modules-8081
[puppet-modules/puppetlabs-apt.git] / spec / acceptance / apt_spec.rb
1 require 'spec_helper_acceptance'
2
3 everything_everything_pp = <<-MANIFEST
4       $sources = {
5         'puppetlabs' => {
6           'ensure'   => present,
7           'location' => 'http://apt.puppetlabs.com',
8           'repos'    => 'main',
9           'key'      => {
10             'id'     => '6F6B15509CF8E59E6E469F327F438280EF8D349F',
11             'server' => 'pool.sks-keyservers.net',
12           },
13         },
14       }
15       class { 'apt':
16         update => {
17           'frequency' => 'always',
18           'timeout'   => 400,
19           'tries'     => 3,
20         },
21         purge => {
22           'sources.list'   => true,
23           'sources.list.d' => true,
24           'preferences'    => true,
25           'preferences.d'  => true,
26         },
27         sources => $sources,
28       }
29   MANIFEST
30
31 describe 'apt class' do
32   context 'with reset' do
33     it 'fixes the sources.list' do
34       shell('cp /etc/apt/sources.list /tmp')
35     end
36   end
37
38   context 'with all the things' do
39     it 'works with no errors' do
40       # Apply the manifest (Retry if timeout error is received from key pool)
41       retry_on_error_matching do
42         apply_manifest(everything_everything_pp, catch_failures: true)
43       end
44     end
45     it 'stills work' do
46       shell('apt-get update')
47       shell('apt-get -y --force-yes upgrade')
48     end
49   end
50
51   context 'with reset' do
52     it 'fixes the sources.list' do
53       shell('cp /tmp/sources.list /etc/apt')
54     end
55   end
56 end