X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=spec%2Fdefines%2Fppa_spec.rb;h=521b42ba2b47897fc99b9c8b59f5769b73dfac59;hb=d3ca10fd2f31d0161bcfc65c263bd044537a3c48;hp=f29a8dfee5664b07098fda9485696daa4b477553;hpb=95ae9ab48ffd76f765d7a7bf7bf5baf2c1299a41;p=puppet-modules%2Fpuppetlabs-apt.git diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index f29a8df..521b42b 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -1,10 +1,10 @@ require 'spec_helper' describe 'apt::ppa' do + let :pre_condition do + 'class { "apt": }' + end describe 'defaults' do - let :pre_condition do - 'class { "apt": }' - end let :facts do { :lsbdistrelease => '11.04', @@ -27,10 +27,91 @@ describe 'apt::ppa' do } end - describe 'apt included, no proxy' do + describe 'ppa depending on ppa, MODULES-1156' do + let :pre_condition do + 'class { "apt": }' + end + end + + describe 'package_name => software-properties-common' do + let :pre_condition do + 'class { "apt": }' + end + let :params do + { + :package_name => 'software-properties-common', + :package_manage => true, + } + end + let :facts do + { + :lsbdistrelease => '11.04', + :lsbdistcodename => 'natty', + :operatingsystem => 'Ubuntu', + :osfamily => 'Debian', + :lsbdistid => 'Ubuntu', + } + end + + let(:title) { 'ppa:needs/such.substitution/wow' } + it { is_expected.to contain_package('software-properties-common') } + it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Exec[apt_update]').with({ + 'environment' => [], + 'command' => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow', + 'unless' => '/usr/bin/test -s /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list', + 'user' => 'root', + 'logoutput' => 'on_failure', + }) + } + + it { is_expected.to contain_file('/etc/apt/sources.list.d/needs-such_substitution-wow-natty.list').that_requires('Exec[add-apt-repository-ppa:needs/such.substitution/wow]').with({ + 'ensure' => 'file', + }) + } + end + + describe 'package_manage => false' do let :pre_condition do 'class { "apt": }' end + let :facts do + { + :lsbdistrelease => '11.04', + :lsbdistcodename => 'natty', + :operatingsystem => 'Ubuntu', + :osfamily => 'Debian', + :lsbdistid => 'Ubuntu', + } + end + let :params do + { + :package_manage => false, + } + end + + let(:title) { 'ppa:needs/such.substitution/wow' } + it { is_expected.to_not contain_package('python-software-properties') } + it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Exec[apt_update]').with({ + 'environment' => [], + 'command' => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow', + 'unless' => '/usr/bin/test -s /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list', + 'user' => 'root', + 'logoutput' => 'on_failure', + }) + } + + it { is_expected.to contain_file('/etc/apt/sources.list.d/needs-such_substitution-wow-natty.list').that_requires('Exec[add-apt-repository-ppa:needs/such.substitution/wow]').with({ + 'ensure' => 'file', + }) + } + end + + describe 'apt included, no proxy' do + let :pre_condition do + 'class { "apt": } + apt::ppa { "ppa:foo2": } + ' + end let :facts do { :lsbdistrelease => '14.04', @@ -42,11 +123,13 @@ describe 'apt::ppa' do end let :params do { - :options => '', + :options => '', :package_manage => true, + :require => 'Apt::Ppa[ppa:foo2]', } end let(:title) { 'ppa:foo' } + it { is_expected.to compile.with_all_deps } it { is_expected.to contain_package('software-properties-common') } it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Exec[apt_update]').with({ :environment => [], @@ -190,6 +273,7 @@ describe 'apt::ppa' do :operatingsystem => 'Ubuntu', :lsbdistid => 'Ubuntu', :osfamily => 'Debian', + :lsbdistcodeanme => nil, } end let(:title) { 'ppa:foo' } @@ -203,10 +287,10 @@ describe 'apt::ppa' do describe 'not ubuntu' do let :facts do { - :lsbdistrelease => '14.04', - :lsbdistcodename => 'trusty', + :lsbdistrelease => '6.0.7', + :lsbdistcodename => 'wheezy', :operatingsystem => 'Debian', - :lsbdistid => 'Ubuntu', + :lsbdistid => 'debian', :osfamily => 'Debian', } end @@ -214,7 +298,7 @@ describe 'apt::ppa' do it do expect { is_expected.to compile - }.to raise_error(Puppet::Error, /supported on Ubuntu and LinuxMint only/) + }.to raise_error(Puppet::Error, /not currently supported on Debian/) end end end