35277bb5912116d54994ebcc3fd5e6013e0a5318
[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 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     it 'stills work' do
49       run_shell('apt-get update')
50       run_shell('apt-get -y --force-yes upgrade')
51     end
52   end
53
54   context 'with reset' do
55     it 'fixes the sources.list' do
56       run_shell('cp /tmp/sources.list /etc/apt')
57     end
58   end
59 end