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