]> review.fuel-infra Code Review - puppet-modules/puppetlabs-apt.git/commitdiff
Changed PPA manifest and tests for new package which started in Quantal
authorJarl Nicolson <jarl@jmn.id.au>
Mon, 5 Nov 2012 09:33:38 +0000 (19:33 +1000)
committerJarl Nicolson <jarl@jmn.id.au>
Mon, 5 Nov 2012 09:33:38 +0000 (19:33 +1000)
manifests/ppa.pp
spec/defines/ppa_spec.rb

index 0458589849e30ec90dcc8f7a7d6f0d73ef6f3c32..9ac4d03ceee6d6250c31766caf5b72d3890e75f2 100644 (file)
@@ -16,9 +16,14 @@ define apt::ppa(
   $filename_without_dots    = regsubst($filename_without_slashes, '\.', '_', G)
   $filename_without_ppa     = regsubst($filename_without_dots, '^ppa:', '', G)
   $sources_list_d_filename  = "${filename_without_ppa}-${release}.list"
-
-  if ! defined(Package['python-software-properties']) {
-    package { 'python-software-properties': }
+  
+  $package = $::lsbdistrelease ? {
+         /^[1-9]\..*|1[01]\..*|12.04$/ => 'python-software-properties',
+         default  => 'software-properties-common',
+  }
+  
+  if ! defined(Package[$package]) {
+    package { $package: }
   }
 
   exec { "add-apt-repository-${name}":
@@ -27,7 +32,7 @@ define apt::ppa(
     logoutput => 'on_failure',
     require   => [
       File[$sources_list_d],
-      Package['python-software-properties'],
+      Package["${package}"],
     ],
     notify    => Exec['apt_update'],
   }
@@ -42,4 +47,3 @@ define apt::ppa(
     require => Class['apt::update'],
   }
 }
-
index d57c1fb854b98d328a2daa87a3dd96a0a670e6b5..6be9ab91426d5247dbf1544c03e828e7e64ce779 100644 (file)
@@ -1,58 +1,82 @@
 require 'spec_helper'
 describe 'apt::ppa', :type => :define do
-  ['ppa:dans_ppa', 'dans_ppa','ppa:dans-daily/ubuntu'].each do |t|
-    describe "with title #{t}" do
-      let :pre_condition do
-        'class { "apt": }'
-      end
+  [ { :lsbdistrelease => '11.04',
+      :lsbdistcodename => 'natty',
+      :package => 'python-software-properties'},
+    { :lsbdistrelease => '12.10',
+      :lsbdistcodename => 'quantal',
+      :package => 'software-properties-common'},
+  ].each do |platform|
+    context "on #{platform[:lsbdistcodename]}" do
       let :facts do
-        {:lsbdistcodename => 'natty'}
-      end
-      let :title do
-        t
+        {
+          :lsbdistrelease => platform[:lsbdistrelease],
+          :lsbdistcodename => platform[:lsbdistcodename],
+        }
       end
       let :release do
-        "natty"
+        "#{platform[:lsbdistcodename]}"
       end
-      let :filename do
-        t.sub(/^ppa:/,'').gsub('/','-') << "-" << "#{release}.list"
+      let :package do
+        "#{platform[:package]}"
       end
+      ['ppa:dans_ppa', 'dans_ppa','ppa:dans-daily/ubuntu'].each do |t|
+        describe "with title #{t}" do
+          let :pre_condition do
+            'class { "apt": }'
+          end
+          let :title do
+            t
+          end
+          let :filename do
+            t.sub(/^ppa:/,'').gsub('/','-') << "-" << "#{release}.list"
+          end
 
-      it { should contain_package("python-software-properties") }
+          it { should contain_package("#{package}") }
 
-      it { should contain_exec("apt_update").with(
-        'command'     => '/usr/bin/apt-get update',
-        'refreshonly' => true
-        )
-      }
+          it { should contain_exec("apt_update").with(
+            'command'     => '/usr/bin/apt-get update',
+            'refreshonly' => true
+            )
+          }
 
-      it { should contain_exec("add-apt-repository-#{t}").with(
-        'command' => "/usr/bin/add-apt-repository #{t}",
-        'creates' => "/etc/apt/sources.list.d/#{filename}",
-        'require' => ["File[/etc/apt/sources.list.d]", "Package[python-software-properties]"],
-        'notify'  => "Exec[apt_update]"
-        )
-      }
+          it { should contain_exec("add-apt-repository-#{t}").with(
+            'command' => "/usr/bin/add-apt-repository #{t}",
+            'creates' => "/etc/apt/sources.list.d/#{filename}",
+            'require' => ["File[/etc/apt/sources.list.d]", "Package[#{package}]"],
+            'notify'  => "Exec[apt_update]"
+            )
+          }
 
-      it { should create_file("/etc/apt/sources.list.d/#{filename}").with(
-        'ensure'  => 'file',
-        'require' => "Exec[add-apt-repository-#{t}]"
-        )
-      }
+          it { should create_file("/etc/apt/sources.list.d/#{filename}").with(
+            'ensure'  => 'file',
+            'require' => "Exec[add-apt-repository-#{t}]"
+            )
+          }
+        end
+      end
     end
   end
 
-  describe "it should not error if package['python-software-properties'] is already defined" do
-    let :pre_condition do
-       'class {"apt": }' +
-       'package { "python-software-properties": }->Apt::Ppa["ppa"]'
-    end
-    let :facts do
-      {:lsbdistcodename => 'natty'}
+  [ { :lsbdistcodename => 'natty', 
+      :package => 'python-software-properties' },
+    { :lsbdistcodename => 'quantal',
+      :package => 'software-properties-common'},
+  ].each do |platform|
+    context "on #{platform[:lsbdistcodename]}" do
+      describe "it should not error if package['#{platform[:package]}'] is already defined" do
+        let :pre_condition do
+           'class {"apt": }' +
+           'package { "#{platform[:package]}": }->Apt::Ppa["ppa"]'
+        end
+        let :facts do
+          {:lsbdistcodename => '#{platform[:lsbdistcodename]}'}
+        end
+        let(:title) { "ppa" }
+        let(:release) { "#{platform[:lsbdistcodename]}" }
+        it { should contain_package('#{platform[:package]}') }
+      end
     end
-    let(:title) { "ppa" }
-    let(:release) { "natty" }
-    it { should contain_package("python-software-properties") }
   end
 
   describe "without Class[apt] should raise a Puppet::Error" do