X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=spec%2Fclasses%2Fapt_spec.rb;h=cd3a6ec7b47f4253418e531179c9804ad5fb5394;hb=e9dadf5ed3308655d003374c4b2c2f5fe8619c27;hp=7578d2eb78d80735f7a85932425e0c207f4117b9;hpb=849d000ff335d460fbb11a4d4ee4a83affff729d;p=puppet-modules%2Fpuppetlabs-apt.git diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 7578d2e..cd3a6ec 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -1,7 +1,14 @@ require 'spec_helper' describe 'apt' do - let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian', :lsbdistcodename => 'wheezy', :puppetversion => Puppet.version} } - + let(:facts) do + { + :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }}, + :lsbdistid => 'Debian', + :osfamily => 'Debian', + :lsbdistcodename => 'wheezy', + :puppetversion => Puppet.version, + } + end context 'defaults' do it { is_expected.to contain_file('sources.list').that_notifies('Class[Apt::Update]').only_with({ :ensure => 'file', @@ -137,9 +144,11 @@ describe 'apt' do context 'with sources defined on valid osfamily' do let :facts do - { :osfamily => 'Debian', + { :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '12', :full => '12.04' }}, + :osfamily => 'Debian', :lsbdistcodename => 'precise', - :lsbdistid => 'Debian', + :lsbdistid => 'Ubuntu', + :lsbdistrelease => '12.04', :puppetversion => Puppet.version, } end @@ -155,7 +164,7 @@ describe 'apt' do 'puppetlabs' => { 'location' => 'http://apt.puppetlabs.com', 'repos' => 'main', - 'key' => { 'id' => '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30', 'server' => 'pgp.mit.edu' }, + 'key' => { 'id' => '6F6B15509CF8E59E6E469F327F438280EF8D349F', 'server' => 'pgp.mit.edu' }, } } } } @@ -177,9 +186,39 @@ describe 'apt' do it { is_expected.to contain_file('/etc/apt/sources.list.d/puppetlabs.list').with_content(/^deb http:\/\/apt.puppetlabs.com precise main$/) } end + context 'with confs defined on valid osfamily' do + let :facts do + { + :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '12', :full => '12.04.5' }}, + :osfamily => 'Debian', + :lsbdistcodename => 'precise', + :lsbdistid => 'Debian', + :puppetversion => Puppet.version, + } + end + let(:params) { { :confs => { + 'foo' => { + 'content' => 'foo', + }, + 'bar' => { + 'content' => 'bar', + } + } } } + + it { is_expected.to contain_apt__conf('foo').with({ + :content => 'foo', + })} + + it { is_expected.to contain_apt__conf('bar').with({ + :content => 'bar', + })} + end + context 'with keys defined on valid osfamily' do let :facts do - { :osfamily => 'Debian', + { + :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '12', :full => '12.04.5' }}, + :osfamily => 'Debian', :lsbdistcodename => 'precise', :lsbdistid => 'Debian', :puppetversion => Puppet.version, @@ -189,7 +228,7 @@ describe 'apt' do '55BE302B' => { 'server' => 'subkeys.pgp.net', }, - '4BD6EC30' => { + 'EF8D349F' => { 'server' => 'pgp.mit.edu', } } } } @@ -198,16 +237,19 @@ describe 'apt' do :server => 'subkeys.pgp.net', })} - it { is_expected.to contain_apt__key('4BD6EC30').with({ + it { is_expected.to contain_apt__key('EF8D349F').with({ :server => 'pgp.mit.edu', })} end context 'with ppas defined on valid osfamily' do let :facts do - { :osfamily => 'Debian', + { + :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '12', :full => '12.04.5' }}, + :osfamily => 'Debian', :lsbdistcodename => 'precise', :lsbdistid => 'ubuntu', + :lsbdistrelease => '12.04', :puppetversion => Puppet.version, } end @@ -222,7 +264,9 @@ describe 'apt' do context 'with settings defined on valid osfamily' do let :facts do - { :osfamily => 'Debian', + { + :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '12', :full => '12.04.5' }}, + :osfamily => 'Debian', :lsbdistcodename => 'precise', :lsbdistid => 'Debian', :puppetversion => Puppet.version, @@ -237,6 +281,25 @@ describe 'apt' do it { is_expected.to contain_apt__setting('pref-banana')} end + context 'with pins defined on valid osfamily' do + let :facts do + { + :os => { :family => 'Debian', :name => 'Ubuntu', :release => { :major => '12', :full => '12.04.5' }}, + :osfamily => 'Debian', + :lsbdistcodename => 'precise', + :lsbdistid => 'Debian', + :puppetversion => Puppet.version, + } + end + let(:params) { { :pins => { + 'stable' => { 'priority' => 600, 'order' => 50 }, + 'testing' => { 'priority' => 700, 'order' => 100 }, + } } } + + it { is_expected.to contain_apt__pin('stable') } + it { is_expected.to contain_apt__pin('testing') } + end + describe 'failing tests' do context "purge['sources.list']=>'banana'" do let(:params) { { :purge => { 'sources.list' => 'banana' }, } } @@ -273,17 +336,5 @@ describe 'apt' do }.to raise_error(Puppet::Error) end end - - context 'with unsupported osfamily' do - let :facts do - { :osfamily => 'Darwin', :puppetversion => Puppet.version,} - end - - it do - expect { - subject.call - }.to raise_error(Puppet::Error, /This module only works on Debian or derivatives like Ubuntu/) - end - end end end