]> review.fuel-infra Code Review - puppet-modules/puppetlabs-apt.git/commitdiff
Merge pull request #145 from PierreGambarotto/master
authorHunter Haugen <h.haugen@gmail.com>
Wed, 31 Jul 2013 16:32:27 +0000 (09:32 -0700)
committerHunter Haugen <h.haugen@gmail.com>
Wed, 31 Jul 2013 16:32:27 +0000 (09:32 -0700)
ppa: fix empty environment definition in exec ressource when no proxy

manifests/ppa.pp
spec/defines/ppa_spec.rb

index db312ea13583e2f01e8c8232605d7901fafbba45..92b6c0e0b28e131af31b3d0903d6de1882aca896 100644 (file)
@@ -31,13 +31,13 @@ define apt::ppa(
     $proxy_host = getparam(Class[apt], "proxy_host")
     $proxy_port = getparam(Class[apt], "proxy_port")
     case  $proxy_host {
-      false: {
-        $proxy_env = ""
+      false, "": {
+        $proxy_env = []
       }
       default: {$proxy_env = ["http_proxy=http://${proxy_host}:${proxy_port}", "https_proxy=http://${proxy_host}:${proxy_port}"]}
     }
   } else {
-    $proxy_env = ""
+    $proxy_env = []
   }
   exec { "add-apt-repository-${name}":
     environment  => $proxy_env,
index d12c70c84d85333fa549669517b07654c9251b17..ae91e585faec0fed07290a0efbdd82b27435ff46 100644 (file)
@@ -58,6 +58,29 @@ describe 'apt::ppa', :type => :define do
           }
         end
       end
+      describe 'without a proxy defined' do
+        let :title do
+          'rspec_ppa'
+        end
+        let :pre_condition do
+          'class { "apt":
+             proxy_host => false
+          }'
+        end
+          let :filename do
+            "#{title}-#{release}.list"
+          end
+
+        it { should contain_exec("add-apt-repository-#{title}").with(
+          'environment' => [],
+          'command'     => "/usr/bin/add-apt-repository #{title}",
+          'creates'     => "/etc/apt/sources.list.d/#{filename}",
+          'require'     => ["File[/etc/apt/sources.list.d]", "Package[#{package}]"],
+          'notify'      => "Exec[apt_update]"
+          )
+        }
+      end
+
       describe 'behind a proxy' do
         let :title do
           'rspec_ppa'