X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=spec%2Fdefines%2Fsource_compat_spec.rb;h=0c42ef1393a31ae26a65e333a9f803756d6a97bd;hb=222d68ee9aca05ab81b6d01994cd88fa73bee5ee;hp=c6b6aefc2eff797b17f6229a2bc94c090e09e037;hpb=dc3ead0ed5f4d735869565660c982983d379a519;p=puppet-modules%2Fpuppetlabs-apt.git diff --git a/spec/defines/source_compat_spec.rb b/spec/defines/source_compat_spec.rb index c6b6aef..0c42ef1 100644 --- a/spec/defines/source_compat_spec.rb +++ b/spec/defines/source_compat_spec.rb @@ -1,23 +1,24 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'apt::source', type: :define do - GPG_KEY_ID = '6F6B15509CF8E59E6E469F327F438280EF8D349F'.freeze + GPG_KEY_ID = '6F6B15509CF8E59E6E469F327F438280EF8D349F' let :title do 'my_source' end - context 'mostly defaults' do - let :facts do - { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, - lsbdistid: 'Debian', - lsbdistcodename: 'wheezy', - osfamily: 'Debian', - puppetversion: Puppet.version, - } - end + let :facts do + { + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, + lsbdistid: 'Debian', + lsbdistcodename: 'jessie', + osfamily: 'Debian', + } + end + context 'with mostly defaults' do let :params do { 'include' => { 'deb' => false, 'src' => true }, @@ -26,20 +27,11 @@ describe 'apt::source', type: :define do end it { - is_expected.to contain_apt__setting('list-my_source').with_content(/# my_source\ndeb-src http:\/\/debian\.mirror\.iweb\.ca\/debian\/ wheezy main\n/) + is_expected.to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb-src http://debian.mirror.iweb.ca/debian/ jessie main\n}) } end - context 'no defaults' do - let :facts do - { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, - lsbdistid: 'Debian', - lsbdistcodename: 'wheezy', - osfamily: 'Debian', - puppetversion: Puppet.version, - } - end + context 'with no defaults' do let :params do { 'comment' => 'foo', @@ -55,7 +47,8 @@ describe 'apt::source', type: :define do end it { - is_expected.to contain_apt__setting('list-my_source').with_content(/# foo\ndeb \[arch=x86_64 trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ sid testing\n/).without_content(%r{deb-src}) # rubocop:disable Metrics/LineLength + is_expected.to contain_apt__setting('list-my_source').with_content(%r{# foo\ndeb \[arch=x86_64 trusted=yes\] http://debian.mirror.iweb.ca/debian/ sid testing\n}) + .without_content(%r{deb-src}) } it { @@ -70,16 +63,7 @@ describe 'apt::source', type: :define do } end - context 'allow_unsigned true' do - let :facts do - { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, - lsbdistid: 'Debian', - lsbdistcodename: 'wheezy', - osfamily: 'Debian', - puppetversion: Puppet.version, - } - end + context 'when allow_unsigned true' do let :params do { 'include' => { 'src' => false }, @@ -88,19 +72,10 @@ describe 'apt::source', type: :define do } end - it { is_expected.to contain_apt__setting('list-my_source').with_content(/# my_source\ndeb \[trusted=yes\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ wheezy main\n/) } + it { is_expected.to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb \[trusted=yes\] http://debian.mirror.iweb.ca/debian/ jessie main\n}) } end - context 'architecture equals x86_64' do - let :facts do - { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, - lsbdistid: 'Debian', - lsbdistcodename: 'wheezy', - osfamily: 'Debian', - puppetversion: Puppet.version, - } - end + context 'with architecture equals x86_64' do let :params do { 'location' => 'http://debian.mirror.iweb.ca/debian/', @@ -109,20 +84,11 @@ describe 'apt::source', type: :define do end it { - is_expected.to contain_apt__setting('list-my_source').with_content(/# my_source\ndeb \[arch=x86_64\] http:\/\/debian\.mirror\.iweb\.ca\/debian\/ wheezy main\n/) + is_expected.to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb \[arch=x86_64\] http://debian.mirror.iweb.ca/debian/ jessie main\n}) } end - context 'ensure => absent' do - let :facts do - { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, - lsbdistid: 'Debian', - lsbdistcodename: 'wheezy', - osfamily: 'Debian', - puppetversion: Puppet.version, - } - end + context 'with ensure => absent' do let :params do { 'ensure' => 'absent', @@ -135,18 +101,16 @@ describe 'apt::source', type: :define do end describe 'validation' do - context 'no release' do + context 'with no release' do let :facts do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, - lsbdistid: 'Debian', + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, osfamily: 'Debian', - puppetversion: Puppet.version, } end it do - expect { subject.call }.to raise_error(Puppet::Error, %r{lsbdistcodename fact not available: release parameter required}) + is_expected.to raise_error(Puppet::Error, %r{lsbdistcodename fact not available: release parameter required}) end end end