fixed test for changing aptitude to apt-get
[puppet-modules/puppetlabs-apt.git] / spec / defines / pin_spec.rb
index 52c6bfae19de80abfff93bbc7ec6c3dbab55064d..3aaf49cef494e79f3b4fce0c2e2e02ba91d7915d 100644 (file)
@@ -4,15 +4,33 @@ describe 'apt::pin', :type => :define do
 
   let :default_params do
     {
+      :ensure   => 'present',
+      :order    => '',
       :packages => '*',
-      :priority => '0'
+      :priority => '0',
+      :release  => nil
     }
   end
 
-  [{},
-   {
+  [ {},
+    {
       :packages  => 'apache',
       :priority  => '1'
+    },
+    {
+      :order     => 50,
+      :packages  => 'apache',
+      :priority  => '1'
+    },
+    {
+      :ensure    => 'absent',
+      :packages  => 'apache',
+      :priority  => '1'
+    },
+    {
+      :packages  => 'apache',
+      :priority  => '1',
+      :release   => 'my_newpin'
     }
   ].each do |param_set|
     describe "when #{param_set == {} ? "using default" : "specifying"} define parameters" do
@@ -27,12 +45,12 @@ describe 'apt::pin', :type => :define do
       it { should include_class("apt::params") }
 
       it { should contain_file("#{title}.pref").with({
-          'path'    => "/etc/apt/preferences.d/#{title}",
-          'ensure'  => "file",
-          'owner'   => "root",
-          'group'   => "root",
-          'mode'    => "644",
-          'content' => "# #{title}\nPackage: #{param_hash[:packages]}\nPin: release a=#{title}\nPin-Priority: #{param_hash[:priority]}"
+          'ensure'  => param_hash[:ensure],
+          'path'    => "/etc/apt/preferences.d/#{param_hash[:order] == '' ? "" : "#{param_hash[:order]}-"}#{title}.pref",
+          'owner'   => 'root',
+          'group'   => 'root',
+          'mode'    => '0644',
+          'content' => "# #{title}\nExplanation: : #{title}\nPackage: #{param_hash[:packages]}\nPin: release a=#{param_hash[:release] || title}\nPin-Priority: #{param_hash[:priority]}\n",
         })
       }
     end