+ context 'with sources defined on valid os.family' do
+ let :facts do
+ {
+ os: {
+ family: 'Debian',
+ name: 'Ubuntu',
+ release: {
+ major: '16',
+ full: '16.04',
+ },
+ distro: {
+ codename: 'xenial',
+ id: 'Ubuntu',
+ },
+ },
+ }
+ end
+ let(:params) do
+ { 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 },
+ },
+ 'puppetlabs' => {
+ 'location' => 'http://apt.puppetlabs.com',
+ 'repos' => 'main',
+ 'key' => { 'id' => '6F6B15509CF8E59E6E469F327F438280EF8D349F', 'server' => 'pgp.mit.edu' },
+ },
+ } }
+ end
+
+ it {
+ is_expected.to contain_apt__setting('list-debian_unstable').with(ensure: 'present')
+ }
+
+ it { is_expected.to contain_file('/etc/apt/sources.list.d/debian_unstable.list').with_content(%r{^deb http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free$}) }
+ it { is_expected.to contain_file('/etc/apt/sources.list.d/debian_unstable.list').with_content(%r{^deb-src http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free$}) }
+
+ it {
+ is_expected.to contain_apt__setting('list-puppetlabs').with(ensure: 'present')
+ }
+
+ it { is_expected.to contain_file('/etc/apt/sources.list.d/puppetlabs.list').with_content(%r{^deb http://apt.puppetlabs.com xenial main$}) }
+ end
+
+ context 'with confs defined on valid os.family' do
+ let :facts do
+ {
+ os: {
+ family: 'Debian',
+ name: 'Ubuntu',
+ release: {
+ major: '16',
+ full: '16.04',
+ },
+ distro: {
+ codename: 'xenial',
+ id: 'Ubuntu',
+ },
+ },
+ }
+ end
+ let(:params) do
+ { confs: {
+ 'foo' => {
+ 'content' => 'foo',
+ },
+ 'bar' => {
+ 'content' => 'bar',
+ },
+ } }
+ end
+
+ it {
+ is_expected.to contain_apt__conf('foo').with(content: 'foo')
+ }
+
+ it {
+ is_expected.to contain_apt__conf('bar').with(content: 'bar')
+ }
+ end
+
+ context 'with keys defined on valid os.family' do
+ let :facts do
+ {
+ os: {
+ family: 'Debian',
+ name: 'Ubuntu',
+ release: {
+ major: '16',
+ full: '16.04',
+ },
+ distro: {
+ codename: 'xenial',
+ id: 'Ubuntu',
+ },
+ },
+ }
+ end
+ let(:params) do
+ { keys: {
+ '55BE302B' => {
+ 'server' => 'subkeys.pgp.net',
+ },
+ 'EF8D349F' => {
+ 'server' => 'pgp.mit.edu',
+ },
+ } }
+ end
+
+ it {
+ is_expected.to contain_apt__key('55BE302B').with(server: 'subkeys.pgp.net')
+ }
+
+ it {
+ is_expected.to contain_apt__key('EF8D349F').with(server: 'pgp.mit.edu')
+ }
+ end
+
+ context 'with ppas defined on valid os.family' do
+ let :facts do
+ {
+ os: {
+ family: 'Debian',
+ name: 'Ubuntu',
+ release: {
+ major: '16',
+ full: '16.04',
+ },
+ distro: {
+ codename: 'xenial',
+ id: 'Ubuntu',
+ },
+ },
+ }
+ end
+ let(:params) do
+ { ppas: {
+ 'ppa:drizzle-developers/ppa' => {},
+ 'ppa:nginx/stable' => {},
+ } }
+ end
+
+ it { is_expected.to contain_apt__ppa('ppa:drizzle-developers/ppa') }
+ it { is_expected.to contain_apt__ppa('ppa:nginx/stable') }
+ end
+
+ context 'with settings defined on valid os.family' do
+ let :facts do
+ {
+ os: {
+ family: 'Debian',
+ name: 'Ubuntu',
+ release: {
+ major: '16',
+ full: '16.04',
+ },
+ distro: {
+ codename: 'xenial',
+ id: 'Ubuntu',
+ },
+ },
+ }
+ end
+ let(:params) do
+ { settings: {
+ 'conf-banana' => { 'content' => 'banana' },
+ 'pref-banana' => { 'content' => 'banana' },
+ } }
+ end
+
+ it { is_expected.to contain_apt__setting('conf-banana') }
+ it { is_expected.to contain_apt__setting('pref-banana') }
+ end
+
+ context 'with pins defined on valid os.family' do
+ let :facts do
+ {
+ os: {
+ family: 'Debian',
+ name: 'Ubuntu',
+ release: {
+ major: '16',
+ full: '16.04',
+ },
+ distro: {
+ codename: 'xenial',
+ id: 'Ubuntu',
+ },
+ },
+ }
+ end
+ let(:params) do
+ { pins: {
+ 'stable' => { 'priority' => 600, 'order' => 50 },
+ 'testing' => { 'priority' => 700, 'order' => 100 },
+ } }
+ end
+
+ it { is_expected.to contain_apt__pin('stable') }
+ it { is_expected.to contain_apt__pin('testing') }
+ end
+
+ describe 'failing tests' do
+ context "with purge['sources.list']=>'banana'" do
+ let(:params) { { purge: { 'sources.list' => 'banana' } } }
+
+ it do
+ is_expected.to raise_error(Puppet::Error)
+ end
+ end
+
+ context "with purge['sources.list.d']=>'banana'" do
+ let(:params) { { purge: { 'sources.list.d' => 'banana' } } }
+
+ it do
+ is_expected.to raise_error(Puppet::Error)
+ end
+ end
+
+ context "with purge['preferences']=>'banana'" do
+ let(:params) { { purge: { 'preferences' => 'banana' } } }
+
+ it do
+ is_expected.to raise_error(Puppet::Error)
+ end
+ end
+
+ context "with purge['preferences.d']=>'banana'" do
+ let(:params) { { purge: { 'preferences.d' => 'banana' } } }
+
+ it do
+ is_expected.to raise_error(Puppet::Error)
+ end
+ end
+
+ context "with purge['apt.conf.d']=>'banana'" do
+ let(:params) { { purge: { 'apt.conf.d' => 'banana' } } }
+
+ it do
+ is_expected.to raise_error(Puppet::Error)
+ end
+ end