From 4b8aa9e55a25d63db0c1c6fcf22a6333f1810e76 Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Fri, 14 Feb 2014 14:49:43 -0800 Subject: [PATCH] Revert "Undo backwards-incompatible changes and features." This reverts commit f9e2fe2a7ce3b2aee5535591b9f6882c29ccc2cb. --- manifests/force.pp | 2 +- manifests/ppa.pp | 2 +- spec/acceptance/apt_ppa_spec.rb | 40 +++++++++++++++++++++++++++++++++ spec/acceptance/force_spec.rb | 6 ++--- spec/defines/force_spec.rb | 26 ++++++++++----------- 5 files changed, 58 insertions(+), 18 deletions(-) diff --git a/manifests/force.pp b/manifests/force.pp index 70b7d47..152bb67 100644 --- a/manifests/force.pp +++ b/manifests/force.pp @@ -2,7 +2,7 @@ # force a package from a specific release define apt::force( - $release = 'testing', + $release = false, $version = false, $timeout = 300 ) { diff --git a/manifests/ppa.pp b/manifests/ppa.pp index caff436..14fbbce 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -1,10 +1,10 @@ # ppa.pp define apt::ppa( + $ensure = 'present', $release = $::lsbdistcodename, $options = '-y' ) { - $ensure = 'present' include apt::params include apt::update diff --git a/spec/acceptance/apt_ppa_spec.rb b/spec/acceptance/apt_ppa_spec.rb index 2b156bc..c0d2161 100644 --- a/spec/acceptance/apt_ppa_spec.rb +++ b/spec/acceptance/apt_ppa_spec.rb @@ -51,12 +51,51 @@ if fact('operatingsystem') == 'Ubuntu' end end + context 'ensure' do + context 'present' do + it 'works without failure' do + pp = <<-EOS + include '::apt' + apt::ppa { 'ppa:canonical-kernel-team/ppa': ensure => present } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe 'contains the source file' do + it 'contains a kernel ppa source' do + shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [0]) + end + end + end + end + + context 'ensure' do + context 'absent' do + it 'works without failure' do + pp = <<-EOS + include '::apt' + apt::ppa { 'ppa:canonical-kernel-team/ppa': ensure => absent } + EOS + + apply_manifest(pp, :catch_failures => true) + end + + describe 'doesnt contain the source file' do + it 'fails' do + shell('ls /etc/apt/sources.list.d/canonical-kernel-team-ppa-*', :acceptable_exit_codes => [2]) + end + end + end + end + context 'release' do context 'precise' do it 'works without failure' do pp = <<-EOS include '::apt' apt::ppa { 'ppa:canonical-kernel-team/ppa': + ensure => present, release => precise, } EOS @@ -77,6 +116,7 @@ if fact('operatingsystem') == 'Ubuntu' pp = <<-EOS include '::apt' apt::ppa { 'ppa:canonical-kernel-team/ppa': + ensure => present, release => precise, options => '-y', } diff --git a/spec/acceptance/force_spec.rb b/spec/acceptance/force_spec.rb index aab77a1..c364d5f 100644 --- a/spec/acceptance/force_spec.rb +++ b/spec/acceptance/force_spec.rb @@ -7,7 +7,7 @@ describe 'apt::force define' do it 'should work with no errors' do pp = <<-EOS include apt - apt::force { 'vim': release => false, } + apt::force { 'vim': } EOS shell('apt-get remove -y vim') @@ -41,7 +41,7 @@ describe 'apt::force define' do it 'should work with no errors' do pp = <<-EOS include apt - apt::force { 'vim': version => '1.1.1', release => false, } + apt::force { 'vim': version => '1.1.1' } EOS shell('apt-get remove -y vim') @@ -59,7 +59,7 @@ describe 'apt::force define' do it 'should work with no errors' do pp = <<-EOS include apt - apt::force { 'vim': release => false, timeout => '1' } + apt::force { 'vim': timeout => '1' } EOS shell('apt-get clean') diff --git a/spec/defines/force_spec.rb b/spec/defines/force_spec.rb index 829ec47..84231fa 100644 --- a/spec/defines/force_spec.rb +++ b/spec/defines/force_spec.rb @@ -10,7 +10,7 @@ describe 'apt::force', :type => :define do let :default_params do { - :release => 'testing', + :release => false, :version => false } end @@ -19,18 +19,18 @@ describe 'apt::force', :type => :define do let :params do default_params end - it { should contain_exec("/usr/bin/apt-get -y -t #{params[:release]} install #{title}").with( - :unless => "/usr/bin/test \$(/usr/bin/apt-cache policy -t #{params[:release]} #{title} | /bin/grep -E 'Installed|Candidate' | /usr/bin/uniq -s 14 | /usr/bin/wc -l) -eq 1", + it { should contain_exec("/usr/bin/apt-get -y install #{title}").with( + :unless => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'", :timeout => '300' ) } end - describe "when specifying false release parameter" do + describe "when specifying release parameter" do let :params do - default_params.merge(:release => false) + default_params.merge(:release => 'testing') end - it { should contain_exec("/usr/bin/apt-get -y install #{title}").with( - :unless => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'" + it { should contain_exec("/usr/bin/apt-get -y -t #{params[:release]} install #{title}").with( + :unless => "/usr/bin/test \$(/usr/bin/apt-cache policy -t #{params[:release]} #{title} | /bin/grep -E 'Installed|Candidate' | /usr/bin/uniq -s 14 | /usr/bin/wc -l) -eq 1" ) } end @@ -38,20 +38,20 @@ describe 'apt::force', :type => :define do let :params do default_params.merge(:version => '1') end - it { should contain_exec("/usr/bin/apt-get -y -t #{params[:release]} install #{title}=#{params[:version]}").with( - :unless => "/usr/bin/apt-cache policy -t #{params[:release]} #{title} | /bin/grep -q 'Installed: #{params[:version]}'" + it { should contain_exec("/usr/bin/apt-get -y install #{title}=#{params[:version]}").with( + :unless => "/usr/bin/dpkg -s #{title} | grep -q 'Version: #{params[:version]}'" ) } end - describe "when specifying false release and version parameters" do + describe "when specifying release and version parameters" do let :params do default_params.merge( - :release => false, + :release => 'testing', :version => '1' ) end - it { should contain_exec("/usr/bin/apt-get -y install #{title}=1").with( - :unless => "/usr/bin/dpkg -s #{title} | grep -q 'Version: #{params[:version]}'" + it { should contain_exec("/usr/bin/apt-get -y -t #{params[:release]} install #{title}=1").with( + :unless => "/usr/bin/apt-cache policy -t #{params[:release]} #{title} | /bin/grep -q 'Installed: #{params[:version]}'" ) } end end -- 2.45.2