X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=spec%2Fdefines%2Fppa_spec.rb;h=a4c30142e872b7edf17fe507933a9235967d5025;hb=e5d46560e4be3b5a17ce5c260f9ed1f051d731c3;hp=521b42ba2b47897fc99b9c8b59f5769b73dfac59;hpb=33c296b963a433c6fe5584b0fd1148c7330c69d0;p=puppet-modules%2Fpuppetlabs-apt.git diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index 521b42b..a4c3014 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -12,15 +12,39 @@ describe 'apt::ppa' do :operatingsystem => 'Ubuntu', :osfamily => 'Debian', :lsbdistid => 'Ubuntu', + :puppetversion => Puppet.version, } end - let(:title) { 'ppa:needs/such.substitution/wow' } + let(:title) { 'ppa:needs/such.substitution/wow+type' } 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({ + it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow+type').that_notifies('Class[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', + :command => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow+type', + :unless => '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow_type-natty.list', + :user => 'root', + :logoutput => 'on_failure', + }) + } + end + + describe 'Ubuntu 15.10 sources.list filename' do + let :facts do + { + :lsbdistrelease => '15.10', + :lsbdistcodename => 'wily', + :operatingsystem => 'Ubuntu', + :osfamily => 'Debian', + :lsbdistid => 'Ubuntu', + :puppetversion => Puppet.version, + } + end + + let(:title) { 'ppa:user/foo' } + it { is_expected.to contain_exec('add-apt-repository-ppa:user/foo').that_notifies('Class[Apt::Update]').with({ + :environment => [], + :command => '/usr/bin/add-apt-repository -y ppa:user/foo', + :unless => '/usr/bin/test -f /etc/apt/sources.list.d/user-ubuntu-foo-wily.list', :user => 'root', :logoutput => 'on_failure', }) @@ -50,15 +74,16 @@ describe 'apt::ppa' do :operatingsystem => 'Ubuntu', :osfamily => 'Debian', :lsbdistid => 'Ubuntu', + :puppetversion => Puppet.version, } 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({ + it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Class[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', + 'unless' => '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list', 'user' => 'root', 'logoutput' => 'on_failure', }) @@ -70,6 +95,46 @@ describe 'apt::ppa' do } end + describe 'package_manage => true, multiple ppas, MODULES-2873' do + let :pre_condition do + 'class { "apt": } + apt::ppa {"ppa:user/foo": + package_manage => true + }' + end + let :facts do + { + :lsbdistrelease => '11.04', + :lsbdistcodename => 'natty', + :operatingsystem => 'Ubuntu', + :osfamily => 'Debian', + :lsbdistid => 'Ubuntu', + :puppetversion => Puppet.version, + } + end + let :params do + { + :package_manage => true, + } + end + + let(:title) { 'ppa:user/bar' } + it { is_expected.to contain_package('python-software-properties') } + it { is_expected.to contain_exec('add-apt-repository-ppa:user/bar').that_notifies('Class[Apt::Update]').with({ + 'environment' => [], + 'command' => '/usr/bin/add-apt-repository -y ppa:user/bar', + 'unless' => '/usr/bin/test -f /etc/apt/sources.list.d/user-bar-natty.list', + 'user' => 'root', + 'logoutput' => 'on_failure', + }) + } + + it { is_expected.to contain_file('/etc/apt/sources.list.d/user-bar-natty.list').that_requires('Exec[add-apt-repository-ppa:user/bar]').with({ + 'ensure' => 'file', + }) + } + end + describe 'package_manage => false' do let :pre_condition do 'class { "apt": }' @@ -81,6 +146,7 @@ describe 'apt::ppa' do :operatingsystem => 'Ubuntu', :osfamily => 'Debian', :lsbdistid => 'Ubuntu', + :puppetversion => Puppet.version, } end let :params do @@ -91,10 +157,10 @@ describe 'apt::ppa' do 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({ + it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Class[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', + 'unless' => '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list', 'user' => 'root', 'logoutput' => 'on_failure', }) @@ -109,7 +175,7 @@ describe 'apt::ppa' do describe 'apt included, no proxy' do let :pre_condition do 'class { "apt": } - apt::ppa { "ppa:foo2": } + apt::ppa { "ppa:user/foo2": } ' end let :facts do @@ -119,22 +185,23 @@ describe 'apt::ppa' do :operatingsystem => 'Ubuntu', :lsbdistid => 'Ubuntu', :osfamily => 'Debian', + :puppetversion => Puppet.version, } end let :params do { :options => '', :package_manage => true, - :require => 'Apt::Ppa[ppa:foo2]', + :require => 'Apt::Ppa[ppa:user/foo2]', } end - let(:title) { 'ppa:foo' } + let(:title) { 'ppa:user/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({ + it { is_expected.to contain_exec('add-apt-repository-ppa:user/foo').that_notifies('Class[Apt::Update]').with({ :environment => [], - :command => '/usr/bin/add-apt-repository ppa:foo', - :unless => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list', + :command => '/usr/bin/add-apt-repository ppa:user/foo', + :unless => '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list', :user => 'root', :logoutput => 'on_failure', }) @@ -154,6 +221,7 @@ describe 'apt::ppa' do :operatingsystem => 'Ubuntu', :lsbdistid => 'Ubuntu', :osfamily => 'Debian', + :puppetversion => Puppet.version, } end let :params do @@ -162,12 +230,12 @@ describe 'apt::ppa' do 'package_manage' => true, } end - let(:title) { 'ppa:foo' } + let(:title) { 'ppa:user/foo' } 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({ + it { is_expected.to contain_exec('add-apt-repository-ppa:user/foo').that_notifies('Class[Apt::Update]').with({ :environment => ['http_proxy=http://localhost:8080'], - :command => '/usr/bin/add-apt-repository ppa:foo', - :unless => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list', + :command => '/usr/bin/add-apt-repository ppa:user/foo', + :unless => '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list', :user => 'root', :logoutput => 'on_failure', }) @@ -187,6 +255,7 @@ describe 'apt::ppa' do :operatingsystem => 'Ubuntu', :lsbdistid => 'Ubuntu', :osfamily => 'Debian', + :puppetversion => Puppet.version, } end let :params do @@ -195,12 +264,12 @@ describe 'apt::ppa' do :package_manage => true, } end - let(:title) { 'ppa:foo' } + let(:title) { 'ppa:user/foo' } 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({ + it { is_expected.to contain_exec('add-apt-repository-ppa:user/foo').that_notifies('Class[Apt::Update]').with({ :environment => ['http_proxy=http://localhost:8180'], - :command => '/usr/bin/add-apt-repository ppa:foo', - :unless => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list', + :command => '/usr/bin/add-apt-repository ppa:user/foo', + :unless => '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list', :user => 'root', :logoutput => 'on_failure', }) @@ -220,6 +289,7 @@ describe 'apt::ppa' do :operatingsystem => 'Ubuntu', :lsbdistid => 'Ubuntu', :osfamily => 'Debian', + :puppetversion => Puppet.version, } end let :params do @@ -228,12 +298,12 @@ describe 'apt::ppa' do :package_manage => true, } end - let(:title) { 'ppa:foo' } + let(:title) { 'ppa:user/foo' } 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({ + it { is_expected.to contain_exec('add-apt-repository-ppa:user/foo').that_notifies('Class[Apt::Update]').with({ :environment => ['http_proxy=http://localhost:8180', 'https_proxy=https://localhost:8180'], - :command => '/usr/bin/add-apt-repository ppa:foo', - :unless => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list', + :command => '/usr/bin/add-apt-repository ppa:user/foo', + :unless => '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list', :user => 'root', :logoutput => 'on_failure', }) @@ -251,15 +321,16 @@ describe 'apt::ppa' do :operatingsystem => 'Ubuntu', :lsbdistid => 'Ubuntu', :osfamily => 'Debian', + :puppetversion => Puppet.version, } end - let(:title) { 'ppa:foo' } + let(:title) { 'ppa:user/foo' } let :params do { :ensure => 'absent' } end - it { is_expected.to contain_file('/etc/apt/sources.list.d/foo-trusty.list').that_notifies('Exec[apt_update]').with({ + it { is_expected.to contain_file('/etc/apt/sources.list.d/user-foo-trusty.list').that_notifies('Class[Apt::Update]').with({ :ensure => 'absent', }) } @@ -274,12 +345,13 @@ describe 'apt::ppa' do :lsbdistid => 'Ubuntu', :osfamily => 'Debian', :lsbdistcodeanme => nil, + :puppetversion => Puppet.version, } end - let(:title) { 'ppa:foo' } + let(:title) { 'ppa:user/foo' } it do expect { - is_expected.to compile + subject.call }.to raise_error(Puppet::Error, /lsbdistcodename fact not available: release parameter required/) end end @@ -292,12 +364,13 @@ describe 'apt::ppa' do :operatingsystem => 'Debian', :lsbdistid => 'debian', :osfamily => 'Debian', + :puppetversion => Puppet.version, } end - let(:title) { 'ppa:foo' } + let(:title) { 'ppa:user/foo' } it do expect { - is_expected.to compile + subject.call }.to raise_error(Puppet::Error, /not currently supported on Debian/) end end