Merge pull request #169 from apenney/fix_ppa.pp
authorAshley Penney <ashley.penney@puppetlabs.com>
Wed, 2 Oct 2013 19:06:32 +0000 (12:06 -0700)
committerAshley Penney <ashley.penney@puppetlabs.com>
Wed, 2 Oct 2013 19:06:32 +0000 (12:06 -0700)
This switches us to doing a `test -s` instead of checking for the

manifests/ppa.pp
spec/defines/ppa_spec.rb
spec/system/apt_builddep_spec.rb
spec/system/apt_key_spec.rb
spec/system/apt_ppa_spec.rb
spec/system/apt_source_spec.rb

index 61b9b3a768dacb352e148ca0de0d53225ad85589..e6954af3b74494187ee4a46392624ec3959d95fe 100644 (file)
@@ -42,7 +42,7 @@ define apt::ppa(
   exec { "add-apt-repository-${name}":
     environment  => $proxy_env,
     command      => "/usr/bin/add-apt-repository ${options} ${name}",
-    creates      => "${sources_list_d}/${sources_list_d_filename}",
+    onlyif       => "/usr/bin/test -s ${sources_list_d}/${sources_list_d_filename}",
     logoutput    => 'on_failure',
     notify       => Exec['apt_update'],
     require      => [
index dfaf09c572c93522f58908876c113aa498b12074..853fdb67f06197887bcde17442fe71e5db7a8762 100644 (file)
@@ -45,7 +45,7 @@ describe 'apt::ppa', :type => :define do
 
           it { should contain_exec("add-apt-repository-#{t}").with(
             'command' => "/usr/bin/add-apt-repository #{options} #{t}",
-            'creates' => "/etc/apt/sources.list.d/#{filename}",
+            'onlyif'  => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}",
             'require' => ["File[/etc/apt/sources.list.d]", "Package[#{package}]"],
             'notify'  => "Exec[apt_update]"
             )
@@ -74,7 +74,7 @@ describe 'apt::ppa', :type => :define do
         it { should contain_exec("add-apt-repository-#{title}").with(
           'environment' => [],
           'command'     => "/usr/bin/add-apt-repository #{options} #{title}",
-          'creates'     => "/etc/apt/sources.list.d/#{filename}",
+          'onlyif'      => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}",
           'require'     => ["File[/etc/apt/sources.list.d]", "Package[#{package}]"],
           'notify'      => "Exec[apt_update]"
           )
@@ -100,7 +100,7 @@ describe 'apt::ppa', :type => :define do
             "https_proxy=http://user:pass@proxy:8080",
           ],
           'command'     => "/usr/bin/add-apt-repository #{options} #{title}",
-          'creates'     => "/etc/apt/sources.list.d/#{filename}",
+          'onlyif'      => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}",
           'require'     => ["File[/etc/apt/sources.list.d]", "Package[#{package}]"],
           'notify'      => "Exec[apt_update]"
           )
index 2fb74870e5cba6a8763fa67d7fa6870314ea199e..fa16ab42f5ffa912927116eb9b77ee0b0e9e1109 100644 (file)
@@ -12,6 +12,7 @@ describe 'apt::builddep' do
   context 'apt::builddep' do
     it 'should work with no errors' do
       pp = <<-EOS
+      include '::apt'
       apt::builddep { 'glusterfs-server': }
       EOS
 
index 2acc3179f281865044281ae810b6d9afa1448e89..4842cb5972ce5aacb6ccd33c2980f4de76d7cc36 100644 (file)
@@ -12,6 +12,7 @@ describe 'apt::key' do
   context 'apt::key' do
     it 'should work with no errors' do
       pp = <<-EOS
+      include '::apt'
       apt::key { 'puppetlabs':
         key        => '4BD6EC30',
         key_server => 'pgp.mit.edu',
index 8e7090bd988ad1e93f8935657ec984e8e09b422a..2e2baf5d2bccc606f5c00d8af7075cfd328490c0 100644 (file)
@@ -5,10 +5,11 @@ describe 'apt::ppa' do
   context 'reset' do
     it 'removes ppa' do
       shell('rm /etc/apt/sources.list.d/drizzle-developers-ppa*')
+      shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*')
     end
   end
 
-  context 'apt::ppa' do
+  context 'adding a ppa that doesnt exist' do
     it 'should work with no errors' do
       pp = <<-EOS
       include '::apt'
@@ -29,9 +30,29 @@ describe 'apt::ppa' do
     end
   end
 
+  context 'readding a removed ppa.' do
+    it 'setup' do
+      shell('add-apt-repository -y ppa:raravena80/collectd5')
+      # This leaves a blank file
+      shell('add-apt-repository --remove ppa:raravena80/collectd5')
+    end
+
+    it 'should readd it successfully' do
+      pp = <<-EOS
+      include '::apt'
+      apt::ppa { 'ppa:raravena80/collectd5': }
+      EOS
+
+      puppet_apply(pp) do |r|
+        r.exit_code.should_not == 1
+      end
+    end
+  end
+
   context 'reset' do
-    it 'removes ppa' do
+    it 'removes added ppas' do
       shell('rm /etc/apt/sources.list.d/drizzle-developers-ppa*')
+      shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*')
     end
   end
 
index 8c79f6f7e0cac85de1d7105561b05f0e6a566bb1..6a445e13eff68d7e74b25bcc49de4fb1a271e104 100644 (file)
@@ -12,6 +12,7 @@ describe 'apt::source' do
   context 'apt::source' do
     it 'should work with no errors' do
       pp = <<-EOS
+      include '::apt'
       apt::source { 'puppetlabs':
         location   => 'http://apt.puppetlabs.com',
         repos      => 'main',