(maint) Unit test fixes
[puppet-modules/puppetlabs-apt.git] / spec / classes / apt_backports_spec.rb
index b9077a6bcd67775a51907f0cb77243f8acf2a7ee..aae4bb0cc150d3c5c977d427c4e1573ed13a525c 100644 (file)
@@ -7,43 +7,50 @@ describe 'apt::backports', :type => :class do
     context 'defaults on deb' do
       let(:facts) do
         {
+          :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
           :lsbdistid       => 'Debian',
           :osfamily        => 'Debian',
           :lsbdistcodename => 'wheezy',
+          :puppetversion   => Puppet.version,
         }
       end
       it { is_expected.to contain_apt__source('backports').with({
-        :location => 'http://ftp.debian.org/debian/',
+        :location => 'http://httpredir.debian.org/debian',
         :key      => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553',
         :repos    => 'main contrib non-free',
         :release  => 'wheezy-backports',
-        :pin      => 200,
+        :pin      => { 'priority' => 200, 'release' => 'wheezy-backports' },
       })
       }
     end
     context 'defaults on squeeze' do
       let(:facts) do
         {
+          :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '6', :full => '6.0' }},
           :lsbdistid       => 'Debian',
           :osfamily        => 'Debian',
           :lsbdistcodename => 'squeeze',
+          :puppetversion   => Puppet.version,
         }
       end
       it { is_expected.to contain_apt__source('backports').with({
-        :location => 'http://backports.debian.org/debian-backports',
+        :location => 'http://httpredir.debian.org/debian-backports',
         :key      => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553',
         :repos    => 'main contrib non-free',
         :release  => 'squeeze-backports',
-        :pin      => 200,
+        :pin      => { 'priority' => 200, 'release' => 'squeeze-backports' },
       })
       }
     end
     context 'defaults on ubuntu' do
       let(:facts) do
         {
+          :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '14', :full => '14.04' }},
           :lsbdistid       => 'Ubuntu',
           :osfamily        => 'Debian',
           :lsbdistcodename => 'trusty',
+          :lsbdistrelease  => '14.04',
+          :puppetversion   => Puppet.version,
         }
       end
       it { is_expected.to contain_apt__source('backports').with({
@@ -51,16 +58,19 @@ describe 'apt::backports', :type => :class do
         :key      => '630239CC130E1A7FD81A27B140976EAF437D05B5',
         :repos    => 'main universe multiverse restricted',
         :release  => 'trusty-backports',
-        :pin      => 200,
+        :pin      => { 'priority' => 200, 'release' => 'trusty-backports' },
       })
       }
     end
     context 'set everything' do
       let(:facts) do
         {
+          :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '14', :full => '14.04' }},
           :lsbdistid       => 'Ubuntu',
           :osfamily        => 'Debian',
           :lsbdistcodename => 'trusty',
+          :lsbdistrelease  => '14.04',
+          :puppetversion   => Puppet.version,
         }
       end
       let(:params) do
@@ -77,16 +87,19 @@ describe 'apt::backports', :type => :class do
         :key      => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553',
         :repos    => 'main',
         :release  => 'vivid',
-        :pin      => 90,
+        :pin      => { 'priority' => 90, 'release' => 'vivid' },
       })
       }
     end
     context 'set things with hashes' do
       let(:facts) do
         {
+          :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '14', :full => '14.04' }},
           :lsbdistid       => 'Ubuntu',
           :osfamily        => 'Debian',
           :lsbdistcodename => 'trusty',
+          :lsbdistrelease  => '14.04',
+          :puppetversion   => Puppet.version,
         }
       end
       let(:params) do
@@ -109,9 +122,11 @@ describe 'apt::backports', :type => :class do
   describe 'mint tests' do
     let(:facts) do
       {
+        :os => { :family => 'Debian', :name => 'Linuxmint', :release => { :major => '17', :full => '17' }},
         :lsbdistid       => 'linuxmint',
         :osfamily        => 'Debian',
         :lsbdistcodename => 'qiana',
+        :puppetversion   => Puppet.version,
       }
     end
     context 'sets all the needed things' do
@@ -128,7 +143,7 @@ describe 'apt::backports', :type => :class do
         :key      => '630239CC130E1A7FD81A27B140976EAF437D05B5',
         :repos    => 'main universe multiverse restricted',
         :release  => 'trusty-backports',
-        :pin      => 200,
+        :pin      => { 'priority' => 200, 'release' => 'trusty-backports' },
       })
       }
     end
@@ -142,7 +157,7 @@ describe 'apt::backports', :type => :class do
       end
       it do
         expect {
-          is_expected.to compile
+          subject.call
         }.to raise_error(Puppet::Error, /If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key/)
       end
     end
@@ -156,7 +171,7 @@ describe 'apt::backports', :type => :class do
       end
       it do
         expect {
-          is_expected.to compile
+          subject.call
         }.to raise_error(Puppet::Error, /If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key/)
       end
     end
@@ -170,7 +185,7 @@ describe 'apt::backports', :type => :class do
       end
       it do
         expect {
-          is_expected.to compile
+          subject.call
         }.to raise_error(Puppet::Error, /If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key/)
       end
     end
@@ -184,7 +199,7 @@ describe 'apt::backports', :type => :class do
       end
       it do
         expect {
-          is_expected.to compile
+          subject.call
         }.to raise_error(Puppet::Error, /If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key/)
       end
     end
@@ -192,9 +207,12 @@ describe 'apt::backports', :type => :class do
   describe 'validation' do
     let(:facts) do
       {
+        :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '14', :full => '14.04' }},
         :lsbdistid       => 'Ubuntu',
         :osfamily        => 'Debian',
         :lsbdistcodename => 'trusty',
+        :lsbdistrelease  => '14.04',
+        :puppetversion   => Puppet.version,
       }
     end
     context 'invalid location' do
@@ -205,8 +223,8 @@ describe 'apt::backports', :type => :class do
       end
       it do
         expect {
-          is_expected.to compile
-        }.to raise_error(Puppet::Error, /is not a string/)
+          subject.call
+        }.to raise_error(Puppet::Error, /expects a value of type Undef or String/)
       end
     end
     context 'invalid release' do
@@ -217,8 +235,8 @@ describe 'apt::backports', :type => :class do
       end
       it do
         expect {
-          is_expected.to compile
-        }.to raise_error(Puppet::Error, /is not a string/)
+          subject.call
+        }.to raise_error(Puppet::Error, /expects a value of type Undef or String/)
       end
     end
     context 'invalid repos' do
@@ -229,8 +247,8 @@ describe 'apt::backports', :type => :class do
       end
       it do
         expect {
-          is_expected.to compile
-        }.to raise_error(Puppet::Error, /is not a string/)
+          subject.call
+        }.to raise_error(Puppet::Error, /expects a value of type Undef or String/)
       end
     end
     context 'invalid key' do
@@ -241,8 +259,8 @@ describe 'apt::backports', :type => :class do
       end
       it do
         expect {
-          is_expected.to compile
-        }.to raise_error(Puppet::Error, /is not a string/)
+          subject.call
+        }.to raise_error(Puppet::Error, /expects a value of type Undef, String, or Hash, got Boolean/)
       end
     end
     context 'invalid pin' do
@@ -253,8 +271,8 @@ describe 'apt::backports', :type => :class do
       end
       it do
         expect {
-          is_expected.to compile
-        }.to raise_error(Puppet::Error, /pin must be either a string, number or hash/)
+          subject.call
+        }.to raise_error(Puppet::Error, /expects a value of type Undef, Integer, String, or Hash, got Boolean/)
       end
     end
   end