]> review.fuel-infra Code Review - puppet-modules/puppetlabs-apt.git/commitdiff
Merge pull request #248 from electrical/fix_params_fail
authorHunter Haugen <hunter@puppetlabs.com>
Fri, 7 Mar 2014 18:00:58 +0000 (10:00 -0800)
committerHunter Haugen <hunter@puppetlabs.com>
Fri, 7 Mar 2014 18:00:58 +0000 (10:00 -0800)
Fix fail message

manifests/init.pp
manifests/params.pp
spec/acceptance/unsupported_spec.rb
spec/classes/apt_spec.rb
spec/classes/debian_testing_spec.rb
spec/classes/debian_unstable_spec.rb
spec/classes/params_spec.rb
spec/defines/ppa_spec.rb

index 7964eb7c08a14bac398059777e2964bfa78beaa5..517391535a931cf1ee6c3c39f03f8020341e6c3c 100644 (file)
@@ -39,6 +39,10 @@ class apt(
   $sources              = undef
 ) {
 
+  if $::osfamily != 'Debian' {
+    fail('This module only works on Debian or derivatives like Ubuntu')
+  }
+
   include apt::params
   include apt::update
 
index 5ef3ccd5c1c9b5d003ad8dce126f032d1fdaa5ac..d23b2db071ab3955fcbf7b2a2b7b39209ce57de2 100644 (file)
@@ -36,7 +36,7 @@ class apt::params {
       }
     }
     default: {
-      fail("Unsupported osfamily (${::osfamily}) or lsbdistid (${::lsbdistid})")
+      fail("Unsupported lsbdistid (${::lsbdistid})")
     }
   }
 }
index 08dca76b845390cd3e3a4444240db9b6682ebe17..3f7468530b91728f99cee6a59d4b0ef17b8b6b72 100644 (file)
@@ -5,6 +5,6 @@ describe 'unsupported distributions and OSes', :if => UNSUPPORTED_PLATFORMS.incl
     pp = <<-EOS
       class { 'apt': }
     EOS
-    expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/unsupported/i)
+    expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/This module only works on Debian or derivatives like Ubuntu/i)
   end
 end
index 7f88dddc3986cc2005357c2e8a1bc210020dfc29..0b677564d1d1cbc84193369f1e1c078e75be4b6d 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,
index 20487333f67ae6b3683998dcd5155c484eb606f5..6e0332652feb24524960e355c8a36ae34bac50fc 100644 (file)
@@ -1,6 +1,6 @@
 require 'spec_helper'
 describe 'apt::debian::testing', :type => :class do
-  let(:facts) { { :lsbdistid => 'Debian' } }
+  let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
   it {
     should contain_apt__source("debian_testing").with({
       "location"            => "http://debian.mirror.iweb.ca/debian/",
index 70724f90bd04d4fefa5441b516b928edfb461629..8477a39e580a84c084ae9fdc8001b7ebff3afcb4 100644 (file)
@@ -1,6 +1,6 @@
 require 'spec_helper'
 describe 'apt::debian::unstable', :type => :class do
-  let(:facts) { { :lsbdistid => 'Debian' } }
+  let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
   it {
     should contain_apt__source("debian_unstable").with({
       "location"          => "http://debian.mirror.iweb.ca/debian/",
index 2d3ec3c71aa8bf0e753e2565534ff9677d9267f8..aa330bb987649ac03eeefc237164b09ad276d3ef 100644 (file)
@@ -1,6 +1,6 @@
 require 'spec_helper'
 describe 'apt::params', :type => :class do
-  let(:facts) { { :lsbdistid => 'Debian' } }
+  let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
   let (:title) { 'my_package' }
 
   it { should contain_apt__params }
@@ -11,4 +11,17 @@ describe 'apt::params', :type => :class do
   it "Should not contain any resources" do
     subject.resources.size.should == 4
   end
+
+  describe "With unknown lsbdistid" do
+
+    let(:facts) { { :lsbdistid => 'CentOS' } }
+    let (:title) { 'my_package' }
+
+    it do
+      expect {
+       should compile
+      }.to raise_error(Puppet::Error, /Unsupported lsbdistid/)
+    end
+
+  end
 end
index 0c3bd75ed779dc64c8a9807eac679c9143b4dccf..6944f9b2dfc8f67d951bb3d53a7179759003e4f0 100644 (file)
@@ -23,6 +23,7 @@ describe 'apt::ppa', :type => :define do
           :lsbdistcodename => platform[:lsbdistcodename],
           :operatingsystem => platform[:operatingsystem],
           :lsbdistid       => platform[:lsbdistid],
+          :osfamily        => 'Debian',
         }
       end
       let :release do
@@ -134,7 +135,8 @@ describe 'apt::ppa', :type => :define do
         let :facts do
           {:lsbdistcodename => '#{platform[:lsbdistcodename]}',
            :operatingsystem => 'Ubuntu',
-           :lsbdistid => 'Ubuntu'}
+           :lsbdistid => 'Ubuntu',
+           :osfamily => 'Debian'}
         end
         let(:title) { "ppa" }
         let(:release) { "#{platform[:lsbdistcodename]}" }