X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=spec%2Fclasses%2Fapt_spec.rb;h=cd3a6ec7b47f4253418e531179c9804ad5fb5394;hb=e014fc04ed8358e4f7c2e87f7434df9817a4c7bb;hp=cc2264bc7a98ef7456e44513036998fa44ba6093;hpb=cc537070e8ee5fbecbbb8f76dc69f39dd79433cc;p=puppet-modules%2Fpuppetlabs-apt.git diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index cc2264b..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,14 +237,16 @@ 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', @@ -223,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, @@ -240,7 +283,9 @@ describe 'apt' do context 'with pins 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, @@ -291,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