[#153] Install unattended configs after package
[puppet-modules/puppetlabs-apt.git] / spec / classes / unattended_upgrades_spec.rb
index 17a21caff1623688703d725f1d9c47552400e857..db5c8557265e0aabda97a8ffc9069b864d1df025 100644 (file)
@@ -10,6 +10,7 @@ describe 'apt::unattended_upgrades', :type => :class do
       "owner"   => "root",
       "group"   => "root",
       "mode"    => "0644",
+      "require" => "Package[unattended-upgrades]",
     })
   }
   
@@ -18,21 +19,36 @@ describe 'apt::unattended_upgrades', :type => :class do
       "owner"   => "root",
       "group"   => "root",
       "mode"    => "0644",
+      "require" => "Package[unattended-upgrades]",
     })
   }
 
-  describe "with origins => ['ubuntu:precise-security']" do
-    let :params do
-      { :origins => ['ubuntu:precise-security'] }
+  describe "origins" do
+    describe "with param defaults" do
+      let(:params) {{ }}
+      it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Allowed-Origins \{\n\t"\${distro_id}:\${distro_codename}-security";\n\};$/) }
+    end
+
+    describe "with origins => ['ubuntu:precise-security']" do
+      let :params do
+        { :origins => ['ubuntu:precise-security'] }
+      end
+      it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Allowed-Origins \{\n\t"ubuntu:precise-security";\n\};$/) }
     end
-    it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Allowed-Origins \{\n\t"ubuntu:precise-security";\n\};$/) }
   end
   
-  describe "with blacklist => []" do
-    let :params do
-      { :blacklist => [] }
+  describe "blacklist" do
+    describe "with param defaults" do
+      let(:params) {{ }}
+      it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Package-Blacklist \{\n\};$/) }
+    end
+
+    describe "with blacklist => []" do
+      let :params do
+        { :blacklist => ['libc6', 'libc6-dev'] }
+      end
+      it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Package-Blacklist \{\n\t"libc6";\n\t"libc6-dev";\n\};$/) }
     end
-    it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Package-Blacklist \{\n\};$/) }
   end
   
   describe "with update => 2" do
@@ -84,21 +100,21 @@ describe 'apt::unattended_upgrades', :type => :class do
     it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::InstallOnShutdown "true";$/) }
   end
   
-  describe "with mail_to => NONE" do
-    let :params do
-      { :mail_to => "NONE" }
+  describe "mail_to" do
+    describe "param defaults" do
+      let(:params) {{ }}
+      it { should_not contain_file(file_unattended).with_content(/^Unattended-Upgrade::Mail /) }
+      it { should_not contain_file(file_unattended).with_content(/^Unattended-Upgrade::MailOnlyOnError /) }
     end
-    it { should contain_file(file_unattended).with_content(/^\/\/ 'mailx' must be installed.\n$/) }
-    it { should contain_file(file_unattended).with_content(/^\/\/ is to always send a mail if Unattended-Upgrade::Mail is set\n$/) }
-  end
-  
-  describe "with mail_to => user@website, mail_only_on_error => true" do
-    let :params do
-      { :mail_to => "user@website",
-        :mail_only_on_error => true }
+
+    describe "with mail_to => user@website, mail_only_on_error => true" do
+      let :params do
+        { :mail_to => "user@website",
+          :mail_only_on_error => true }
+      end
+      it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Mail "user@website";$/) }
+      it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::MailOnlyOnError "true";$/) }
     end
-    it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Mail "user@website";$/) }
-    it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::MailOnlyOnError "true";$/) }
   end
   
   describe "with remove_unused => false" do
@@ -115,11 +131,18 @@ describe 'apt::unattended_upgrades', :type => :class do
     it { should contain_file(file_unattended).with_content(/^Unattended-Upgrade::Automatic-Reboot "true";$/) }
   end
   
-  describe "with dl_limit => 70" do
-    let :params do
-      { :dl_limit => "70" }
+  describe "dl_limit" do
+    describe "param defaults" do
+      let(:params) {{ }}
+      it { should_not contain_file(file_unattended).with_content(/^Acquire::http::Dl-Limit /) }
+    end
+
+    describe "with dl_limit => 70" do
+      let :params do
+        { :dl_limit => "70" }
+      end
+      it { should contain_file(file_unattended).with_content(/^Acquire::http::Dl-Limit "70";$/) }
     end
-    it { should contain_file(file_unattended).with_content(/^Acquire::http::Dl-Limit "70";$/) }
   end
   
   describe "with enable => 0" do