diff options
author | kwadronaut <kwadronaut@leap.se> | 2018-09-27 01:19:23 +0200 |
---|---|---|
committer | kwadronaut <kwadronaut@leap.se> | 2018-09-27 01:19:23 +0200 |
commit | 0c0a8d7f621912a9d7727c16331923d216921dd1 (patch) | |
tree | 6117b7a81a066453b06893304643b8cadca286ed /spec/classes | |
parent | 27e33591776f0226f78877df350d6a52995265d8 (diff) | |
parent | f0faa776b9cd8c9cfbe16651de2fce6b37df4dfb (diff) |
Merge tag '1.6.1'
Diffstat (limited to 'spec/classes')
-rw-r--r-- | spec/classes/augeas_spec.rb | 183 |
1 files changed, 120 insertions, 63 deletions
diff --git a/spec/classes/augeas_spec.rb b/spec/classes/augeas_spec.rb index ab4241f..16f76f4 100644 --- a/spec/classes/augeas_spec.rb +++ b/spec/classes/augeas_spec.rb @@ -10,10 +10,12 @@ describe 'augeas' do end it 'should fail' do - expect { is_expected.to contain_package('ruby-augeas') }.to raise_error(Puppet::Error, /Unsupported OS family/) + expect { is_expected.to compile }.to raise_error(/Unsupported OS family/) end end + lens_dir = Puppet.version < '4.0.0' ? '/usr/share/augeas/lenses' : '/opt/puppetlabs/puppet/share/augeas/lenses' + on_supported_os.each do |os, facts| context "on #{os}" do let(:facts) do @@ -21,53 +23,65 @@ describe 'augeas' do end context 'without params' do - case facts[:osfamily] - when 'Debian' - it { is_expected.to contain_package('libaugeas0').with( - :ensure => 'present' - ) } - it { is_expected.to contain_package('augeas-tools').with( - :ensure => 'present' - ) } - it { is_expected.to contain_package('augeas-lenses').with( - :ensure => 'present' - ) } - case facts[:lsbdistcodename] - when 'squeeze', 'lucid', 'precise' - it { is_expected.to contain_package('ruby-augeas').with( - :ensure => 'present', - :name => 'libaugeas-ruby1.8' + if Puppet.version < '4.0.0' + case facts[:osfamily] + when 'Debian' + it { is_expected.to contain_package('libaugeas0').with( + :ensure => 'present' + ) } + it { is_expected.to contain_package('augeas-tools').with( + :ensure => 'present' + ) } + it { is_expected.to contain_package('augeas-lenses').with( + :ensure => 'present' + ) } + case facts[:lsbdistcodename] + when 'squeeze', 'lucid', 'precise' + let(:facts) do + super().merge({ + :rubyversion => '1.8.7', + }) + end + it { is_expected.to contain_package('ruby-augeas').with( + :ensure => 'present', + :name => 'libaugeas-ruby1.8' + ) } + else + let(:facts) do + super().merge({ + :rubyversion => '1.9.3', + }) + end + it { is_expected.to contain_package('ruby-augeas').with( + :ensure => 'present', + :name => 'libaugeas-ruby1.9.1' + ) } + end + when 'RedHat' + it { is_expected.to contain_package('augeas').with( + :ensure => 'present' + ) } + it { is_expected.to contain_package('augeas-libs').with( + :ensure => 'present' ) } - else it { is_expected.to contain_package('ruby-augeas').with( :ensure => 'present', - :name => 'libaugeas-ruby1.9.1' + :name => 'ruby-augeas' ) } end - when 'RedHat' - it { is_expected.to contain_package('augeas').with( - :ensure => 'present' - ) } - it { is_expected.to contain_package('augeas-libs').with( - :ensure => 'present' - ) } - it { is_expected.to contain_package('ruby-augeas').with( - :ensure => 'present', - :name => 'ruby-augeas' - ) } end - it { is_expected.to contain_file('/usr/share/augeas/lenses').with( + it { is_expected.to contain_file(lens_dir).with( :ensure => 'directory', :purge => 'true', :force => 'true', :recurse => 'true', :recurselimit => 1 ) } - it { is_expected.to contain_file('/usr/share/augeas/lenses/dist').with( + it { is_expected.to contain_file("#{lens_dir}/dist").with( :ensure => 'directory', :purge => 'false' ) } - it { is_expected.to contain_file('/usr/share/augeas/lenses/tests').with( + it { is_expected.to contain_file("#{lens_dir}/tests").with( :ensure => 'directory', :purge => 'true', :force => 'true' @@ -82,42 +96,53 @@ describe 'augeas' do } end - case facts[:osfamily] - when 'Debian' - it { is_expected.to contain_package('libaugeas0').with( - :ensure => '1.2.3' - ) } - it { is_expected.to contain_package('augeas-tools').with( - :ensure => '1.2.3' - ) } - it { is_expected.to contain_package('augeas-lenses').with( - :ensure => '1.2.3' - ) } - case facts[:lsbdistcodename] - when 'squeeze', 'lucid', 'precise' - it { is_expected.to contain_package('ruby-augeas').with( - :ensure => '3.2.1', - :name => 'libaugeas-ruby1.8' + if Puppet.version < '4.0.0' + case facts[:osfamily] + when 'Debian' + it { is_expected.to contain_package('libaugeas0').with( + :ensure => '1.2.3' + ) } + it { is_expected.to contain_package('augeas-tools').with( + :ensure => '1.2.3' + ) } + it { is_expected.to contain_package('augeas-lenses').with( + :ensure => '1.2.3' + ) } + case facts[:lsbdistcodename] + when 'squeeze', 'lucid', 'precise' + let(:facts) do + super().merge({ + :rubyversion => '1.8.7', + }) + end + it { is_expected.to contain_package('ruby-augeas').with( + :ensure => '3.2.1', + :name => 'libaugeas-ruby1.8' + ) } + else + let(:facts) do + super().merge({ + :rubyversion => '1.9.3', + }) + end + it { is_expected.to contain_package('ruby-augeas').with( + :ensure => '3.2.1', + :name => 'libaugeas-ruby1.9.1' + ) } + end + when 'RedHat' + it { is_expected.to contain_package('augeas').with( + :ensure => '1.2.3' + ) } + it { is_expected.to contain_package('augeas-libs').with( + :ensure => '1.2.3' ) } - else it { is_expected.to contain_package('ruby-augeas').with( :ensure => '3.2.1', - :name => 'libaugeas-ruby1.9.1' + :name => 'ruby-augeas' ) } end - when 'RedHat' - it { is_expected.to contain_package('augeas').with( - :ensure => '1.2.3' - ) } - it { is_expected.to contain_package('augeas-libs').with( - :ensure => '1.2.3' - ) } - it { is_expected.to contain_package('ruby-augeas').with( - :ensure => '3.2.1', - :name => 'ruby-augeas' - ) } end - end context 'with a non standard lens_dir' do @@ -144,6 +169,38 @@ describe 'augeas' do :force => 'true' ).without(:recurse) } end + + context 'with Puppet Enterprise' do + let (:facts) do + facts.merge({ + :is_pe => true, + }) + end + + if Puppet::Util::Package.versioncmp(Puppet.version, '4.0.0') >= 0 + # the enterprise lens dir is the same in 4 + pe_lens_dir = lens_dir + else + pe_lens_dir = '/opt/puppet/share/augeas/lenses' + end + + it { is_expected.to contain_file(pe_lens_dir).with( + :ensure => 'directory', + :force => 'true', + :recurse => 'true', + :recurselimit => 1 + ) } + it { is_expected.to contain_file("#{pe_lens_dir}/dist").with( + :ensure => 'directory', + :purge => 'false' + ) } + it { is_expected.to contain_file("#{pe_lens_dir}/tests").with( + :ensure => 'directory', + :force => 'true', + :purge => 'true' + ).without(:recurse) } + end + end end end |