Unbreak broken tests
[puppet-modules/puppetlabs-apt.git] / spec / classes / unattended_upgrades_spec.rb
index 291719b0098b66e986bfeb4cfee5b61cc6ff47bd..e0a6ebf72236cd411314fcf9af24c150ad0ec13f 100644 (file)
@@ -2,7 +2,7 @@ require 'spec_helper'
 describe 'apt::unattended_upgrades', :type => :class do
   let(:file_unattended) { '/etc/apt/apt.conf.d/50unattended-upgrades' }
   let(:file_periodic) { '/etc/apt/apt.conf.d/10periodic' }
-  let(:facts) { { :lsbdistid => 'Debian' } }
+  let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
 
   it { should contain_package("unattended-upgrades") }
 
@@ -29,6 +29,7 @@ describe 'apt::unattended_upgrades', :type => :class do
       {
         'lsbdistid'       => 'debian',
         'lsbdistcodename' => 'squeeze',
+        'osfamily'        => 'Debian',
       }
     end
     context 'bad auto_fix' do
@@ -94,6 +95,14 @@ describe 'apt::unattended_upgrades', :type => :class do
       it { expect { should raise_error(Puppet::Error) } }
     end
 
+    context 'bad randomsleep' do
+      let :params do
+        {
+          'randomsleep' => '4ever'
+        }
+      end
+      it { expect { should raise_error(Puppet::Error) } }
+    end
   end
 
   context 'defaults' do
@@ -101,6 +110,7 @@ describe 'apt::unattended_upgrades', :type => :class do
       {
         'lsbdistid'       => 'debian',
         'lsbdistcodename' => 'squeeze',
+        'osfamily'        => 'Debian',
       }
     end
 
@@ -123,6 +133,19 @@ describe 'apt::unattended_upgrades', :type => :class do
     it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Unattended-Upgrade "1";}}
     it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::AutocleanInterval "7";}}
     it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Verbose "0";}}
+    it { is_expected.to_not contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::RandomSleep}}
+  end
+
+  context 'wheezy' do
+    let :facts do
+      {
+        'lsbdistid'       => 'debian',
+        'lsbdistcodename' => 'wheezy',
+        'osfamily'        => 'Debian',
+      }
+    end
+
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/50unattended-upgrades").with_content %r{Unattended-Upgrade::Origins-Pattern \{\n\t"origin=Debian,archive=stable,label=Debian-Security";\n\t"origin=Debian,archive=oldstable,label=Debian-Security";\n\};} }
   end
 
   context 'anything but defaults' do
@@ -130,6 +153,7 @@ describe 'apt::unattended_upgrades', :type => :class do
       {
         'lsbdistid'       => 'debian',
         'lsbdistcodename' => 'wheezy',
+        'osfamily'        => 'Debian',
       }
     end
 
@@ -157,6 +181,7 @@ describe 'apt::unattended_upgrades', :type => :class do
         'remove_unused'       => false,
         'auto_reboot'         => true,
         'dl_limit'            => '70',
+        'randomsleep'         => '1799',
       }
     end
 
@@ -183,6 +208,7 @@ describe 'apt::unattended_upgrades', :type => :class do
     it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Unattended-Upgrade "0";}}
     it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::AutocleanInterval "0";}}
     it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::Verbose "1";}}
+    it { is_expected.to contain_file("/etc/apt/apt.conf.d/10periodic").with_content %r{APT::Periodic::RandomSleep "1799";}}
 
   end
 end