ppa: fix empty environment definition in exec ressource when no proxy
authorPierre Gambarotto <pierre.gambarotto@enseeiht.fr>
Tue, 16 Jul 2013 07:52:06 +0000 (09:52 +0200)
committerPierre Gambarotto <pierre.gambarotto@enseeiht.fr>
Tue, 16 Jul 2013 07:52:06 +0000 (09:52 +0200)
manifests/ppa.pp
spec/defines/ppa_spec.rb

index f234f748e7c6921fd16687669ee13f5cc6ee45d1..6cb921f19bec95951ff52a554b0f8cb096f4ed39 100644 (file)
@@ -30,13 +30,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 3baa7e86572fde065302a52258349ae4200611e4..b768b25d3fbf9ca899b3c48a5c7b3c14f584666e 100644 (file)
@@ -55,6 +55,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'