X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=spec%2Fdefines%2Fppa_spec.rb;h=b0e689e236f24bd4291f031bef441d3569f36365;hb=c5259f83ad20d120d502d8541c75f4ee6021fec8;hp=89e5b36c57f4373590e27eae895bc93636e652bb;hpb=f610bedc5f33db5fdee2ad49eeda95268ab0b9a5;p=puppet-modules%2Fpuppetlabs-apt.git diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index 89e5b36..b0e689e 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe 'apt::ppa' do let :pre_condition do @@ -7,13 +9,12 @@ describe 'apt::ppa' do describe 'defaults' do let :facts do { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '11', full: '11.04' } }, - lsbdistrelease: '11.04', - lsbdistcodename: 'natty', + os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '41.04' } }, + lsbdistrelease: '14.04', + lsbdistcodename: 'trusty', operatingsystem: 'Ubuntu', osfamily: 'Debian', lsbdistid: 'Ubuntu', - puppetversion: Puppet.version, } end @@ -22,8 +23,8 @@ describe 'apt::ppa' do it { is_expected.not_to contain_package('python-software-properties') } 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+type', # rubocop:disable Metrics/LineLength - unless: '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow_type-natty.list', # rubocop:disable Metrics/LineLength + command: '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow+type || (rm /etc/apt/sources.list.d/needs-such_substitution-wow_type-trusty.list && false)', # rubocop:disable Layout/LineLength + unless: '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow_type-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/needs-such_substitution-wow_type.gpg', # rubocop:disable Layout/LineLength user: 'root', logoutput: 'on_failure') } @@ -38,7 +39,6 @@ describe 'apt::ppa' do operatingsystem: 'Ubuntu', osfamily: 'Debian', lsbdistid: 'Ubuntu', - puppetversion: Puppet.version, } end @@ -46,19 +46,13 @@ describe 'apt::ppa' do 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', + command: '/usr/bin/add-apt-repository -y ppa:user/foo || (rm /etc/apt/sources.list.d/user-ubuntu-foo-wily.list && false)', # rubocop:disable Layout/LineLength + unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-ubuntu-foo-wily.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/user_ubuntu_foo.gpg', # rubocop:disable Layout/LineLength user: 'root', logoutput: 'on_failure') } end - 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": }' @@ -71,13 +65,12 @@ describe 'apt::ppa' do end let :facts do { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '11', full: '11.04' } }, - lsbdistrelease: '11.04', - lsbdistcodename: 'natty', + os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } }, + lsbdistrelease: '14.04', + lsbdistcodename: 'trusty', operatingsystem: 'Ubuntu', osfamily: 'Debian', lsbdistid: 'Ubuntu', - puppetversion: Puppet.version, } end @@ -86,54 +79,14 @@ describe 'apt::ppa' do 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('Class[Apt::Update]').with('environment' => [], - 'command' => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow', # rubocop:disable Metrics/LineLength - 'unless' => '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list', # rubocop:disable Metrics/LineLength + 'command' => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow || (rm /etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list && false)', # rubocop:disable Layout/LineLength + 'unless' => '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/needs-such_substitution-wow.gpg', # rubocop:disable Layout/LineLength '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 => true, multiple ppas, MODULES-2873' do - let :pre_condition do - 'class { "apt": } - apt::ppa {"ppa:user/foo": - package_manage => true - }' - end - let :facts do - { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '11', full: '11.04' } }, - 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') + is_expected.to contain_file('/etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list').that_requires('Exec[add-apt-repository-ppa:needs/such.substitution/wow]').with('ensure' => 'file') } end @@ -143,13 +96,12 @@ describe 'apt::ppa' do end let :facts do { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '11', full: '11.04' } }, - lsbdistrelease: '11.04', - lsbdistcodename: 'natty', + os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } }, + lsbdistrelease: '14.04', + lsbdistcodename: 'trusty', operatingsystem: 'Ubuntu', osfamily: 'Debian', lsbdistid: 'Ubuntu', - puppetversion: Puppet.version, } end let :params do @@ -163,14 +115,14 @@ describe 'apt::ppa' do it { is_expected.not_to contain_package('python-software-properties') } 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', # rubocop:disable Metrics/LineLength - 'unless' => '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list', # rubocop:disable Metrics/LineLength + 'command' => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow || (rm /etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list && false)', # rubocop:disable Layout/LineLength + 'unless' => '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/needs-such_substitution-wow.gpg', # rubocop:disable Layout/LineLength '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') + is_expected.to contain_file('/etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list').that_requires('Exec[add-apt-repository-ppa:needs/such.substitution/wow]').with('ensure' => 'file') } end @@ -188,7 +140,6 @@ describe 'apt::ppa' do operatingsystem: 'Ubuntu', lsbdistid: 'Ubuntu', osfamily: 'Debian', - puppetversion: Puppet.version, } end let :params do @@ -204,8 +155,8 @@ describe 'apt::ppa' do it { is_expected.to contain_package('software-properties-common') } 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:user/foo', - unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list', + command: '/usr/bin/add-apt-repository ppa:user/foo || (rm /etc/apt/sources.list.d/user-foo-trusty.list && false)', # rubocop:disable Layout/LineLength + unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/user-foo.gpg', # rubocop:disable Layout/LineLength user: 'root', logoutput: 'on_failure') } @@ -225,7 +176,6 @@ describe 'apt::ppa' do operatingsystem: 'Ubuntu', lsbdistid: 'Ubuntu', osfamily: 'Debian', - puppetversion: Puppet.version, } end let :params do @@ -239,8 +189,8 @@ describe 'apt::ppa' do it { is_expected.to contain_package('software-properties-common') } 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:user/foo', - unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list', + command: '/usr/bin/add-apt-repository ppa:user/foo || (rm /etc/apt/sources.list.d/user-foo-trusty.list && false)', # rubocop:disable Layout/LineLength + unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/user-foo.gpg', # rubocop:disable Layout/LineLength user: 'root', logoutput: 'on_failure') } @@ -260,7 +210,6 @@ describe 'apt::ppa' do operatingsystem: 'Ubuntu', lsbdistid: 'Ubuntu', osfamily: 'Debian', - puppetversion: Puppet.version, } end let :params do @@ -274,8 +223,8 @@ describe 'apt::ppa' do it { is_expected.to contain_package('software-properties-common') } 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:user/foo', - unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list', + command: '/usr/bin/add-apt-repository ppa:user/foo || (rm /etc/apt/sources.list.d/user-foo-trusty.list && false)', # rubocop:disable Layout/LineLength + unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/user-foo.gpg', # rubocop:disable Layout/LineLength user: 'root', logoutput: 'on_failure') } @@ -295,7 +244,6 @@ describe 'apt::ppa' do operatingsystem: 'Ubuntu', lsbdistid: 'Ubuntu', osfamily: 'Debian', - puppetversion: Puppet.version, } end let :params do @@ -309,8 +257,8 @@ describe 'apt::ppa' do it { is_expected.to contain_package('software-properties-common') } 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:user/foo', - unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list', + command: '/usr/bin/add-apt-repository ppa:user/foo || (rm /etc/apt/sources.list.d/user-foo-trusty.list && false)', # rubocop:disable Layout/LineLength + unless: '/usr/bin/test -f /etc/apt/sources.list.d/user-foo-trusty.list && /usr/bin/test -f /etc/apt/trusted.gpg.d/user-foo.gpg', # rubocop:disable Layout/LineLength user: 'root', logoutput: 'on_failure') } @@ -328,7 +276,6 @@ describe 'apt::ppa' do operatingsystem: 'Ubuntu', lsbdistid: 'Ubuntu', osfamily: 'Debian', - puppetversion: Puppet.version, } end let(:title) { 'ppa:user/foo' } @@ -343,7 +290,7 @@ describe 'apt::ppa' do } end - context 'validation' do + context 'with validation' do describe 'no release' do let :facts do { @@ -353,15 +300,12 @@ describe 'apt::ppa' do lsbdistid: 'Ubuntu', osfamily: 'Debian', lsbdistcodeanme: nil, - puppetversion: Puppet.version, } end let(:title) { 'ppa:user/foo' } it do - expect { - subject.call - }.to raise_error(Puppet::Error, %r{lsbdistcodename fact not available: release parameter required}) + is_expected.to raise_error(Puppet::Error, %r{lsbdistcodename fact not available: release parameter required}) end end @@ -374,15 +318,12 @@ describe 'apt::ppa' do operatingsystem: 'Debian', lsbdistid: 'debian', osfamily: 'Debian', - puppetversion: Puppet.version, } end let(:title) { 'ppa:user/foo' } it do - expect { - subject.call - }.to raise_error(Puppet::Error, %r{not currently supported on Debian}) + is_expected.to raise_error(Puppet::Error, %r{not currently supported on Debian}) end end end