Merge branch '1.4.x' into 14x-merge
[puppet-modules/puppetlabs-apt.git] / spec / classes / apt_spec.rb
index 080bc81760282c70a9bf7b5a45249f06a645bd5d..a21e0443e2df715b221e712d9457607d26117611 100644 (file)
@@ -1,6 +1,6 @@
 require 'spec_helper'
 describe 'apt', :type => :class do
-  let(:facts) { { :lsbdistid => 'Debian' } }
+  let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
   let :default_params do
     {
       :disable_keys => :undef,
@@ -19,6 +19,10 @@ describe 'apt', :type => :class do
       :purge_sources_list => true,
       :purge_sources_list_d => true,
     },
+    {
+      :purge_preferences   => true,
+      :purge_preferences_d => true,
+    },
     {
       :disable_keys => false
     }
@@ -86,6 +90,38 @@ describe 'apt', :type => :class do
           })
         end
       }
+      it {
+        if param_hash[:purge_preferences]
+          should create_file('apt-preferences').with({
+            :ensure  => 'absent',
+            :path    => '/etc/apt/preferences',
+          })
+        else
+          should_not contain_file('apt-preferences')
+        end
+      }
+
+      it {
+        if param_hash[:purge_preferences_d]
+          should create_file("preferences.d").with({
+            'path'    => "/etc/apt/preferences.d",
+            'ensure'  => "directory",
+            'owner'   => "root",
+            'group'   => "root",
+            'purge'   => true,
+            'recurse' => true,
+          })
+        else
+          should create_file("preferences.d").with({
+            'path'    => "/etc/apt/preferences.d",
+            'ensure'  => "directory",
+            'owner'   => "root",
+            'group'   => "root",
+            'purge'   => false,
+            'recurse' => false,
+          })
+        end
+      }
 
       it {
         should contain_exec("apt_update").with({
@@ -115,14 +151,14 @@ describe 'apt', :type => :class do
       describe 'when setting a proxy' do
         it {
           if param_hash[:proxy_host]
-            should contain_file('configure-apt-proxy').with(
-              'path'    => '/etc/apt/apt.conf.d/proxy',
-              'content' => "Acquire::http::Proxy \"http://#{param_hash[:proxy_host]}:#{param_hash[:proxy_port]}\";",
+            should contain_file('01proxy').with(
+              'path'    => '/etc/apt/apt.conf.d/01proxy',
+              'content' => "Acquire::http::Proxy \"http://#{param_hash[:proxy_host]}:#{param_hash[:proxy_port]}\";\n",
               'notify'  => "Exec[apt_update]"
             )
           else
-            should contain_file('configure-apt-proxy').with(
-              'path'    => '/etc/apt/apt.conf.d/proxy',
+            should contain_file('01proxy').with(
+              'path'    => '/etc/apt/apt.conf.d/01proxy',
               'notify'  => 'Exec[apt_update]',
               'ensure'  => 'absent'
             )