- let(:params) { { :sources => {
- 'debian_unstable' => {
- 'location' => 'http://debian.mirror.iweb.ca/debian/',
- 'release' => 'unstable',
- 'repos' => 'main contrib non-free',
- 'key' => { 'id' => '150C8614919D8446E01E83AF9AA38DCD55BE302B', 'server' => 'subkeys.pgp.net' },
- 'pin' => '-10',
- 'include' => {'src' => true,},
+
+ it {
+ is_expected.to contain_file('sources.list').with(content: "# Repos managed by puppet.\n")
+ }
+
+ it {
+ is_expected.to contain_file('sources.list.d').with(purge: true,
+ recurse: true)
+ }
+
+ it {
+ is_expected.to contain_file('preferences').with(ensure: 'absent')
+ }
+
+ it {
+ is_expected.to contain_file('preferences.d').with(purge: true,
+ recurse: true)
+ }
+
+ it {
+ is_expected.to contain_file('apt.conf.d').with(purge: true,
+ recurse: true)
+ }
+
+ it {
+ is_expected.to contain_exec('apt_update').with(refreshonly: false,
+ timeout: 1,
+ tries: 3)
+ }
+ end
+
+ context 'with defaults for sources_list_force' do
+ let :params do
+ {
+ update: { 'frequency' => 'always', 'timeout' => 1, 'tries' => 3 },
+ purge: { 'sources.list' => true },
+ sources_list_force: false,
+ }
+ end
+
+ it {
+ is_expected.to contain_file('sources.list').with(content: "# Repos managed by puppet.\n")
+ }
+ end
+
+ context 'with non defaults for sources_list_force' do
+ let :params do
+ {
+ update: { 'frequency' => 'always', 'timeout' => 1, 'tries' => 3 },
+ purge: { 'sources.list' => true },
+ sources_list_force: true,
+ }
+ end
+
+ it {
+ is_expected.to contain_file('sources.list').with(ensure: 'absent')
+ }
+ end
+
+ context 'with entries for /etc/apt/auth.conf' do
+ facts_hash = {
+ 'Ubuntu 14.04' => {
+ os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } },
+ osfamily: 'Debian',
+ lsbdistcodename: 'trusty',
+ lsbdistid: 'Ubuntu',
+ lsbdistrelease: '14.04',
+ },
+ 'Ubuntu 16.04' => {
+ os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } },
+ osfamily: 'Debian',
+ lsbdistcodename: 'xenial',
+ lsbdistid: 'Ubuntu',
+ lsbdistrelease: '16.04',
+ },
+ 'Ubuntu 18.04' => {
+ os: { family: 'Debian', name: 'Ubuntu', release: { major: '18', full: '18.04' } },
+ osfamily: 'Debian',
+ lsbdistcodename: 'bionic',
+ lsbdistid: 'Ubuntu',
+ lsbdistrelease: '18.04',
+ },
+ 'Debian 7.0' => {
+ os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } },
+ lsbdistid: 'Debian',
+ osfamily: 'Debian',
+ lsbdistcodename: 'wheezy',
+ },
+ 'Debian 8.0' => {
+ os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } },
+ lsbdistid: 'Debian',
+ osfamily: 'Debian',
+ lsbdistcodename: 'jessie',