X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=spec%2Fdefines%2Fppa_spec.rb;h=ba234fd8059d108e5326901aa0c3973d14eaba4c;hb=bfab353ff609b0cc725a212a879ad6f7a7e4e8de;hp=7a11811e461dea4d6f4d0e845c27495aecd54e14;hpb=4ea96b8d7ec3dd0d6acabb1d7718f96b8def614c;p=puppet-modules%2Fpuppetlabs-apt.git diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index 7a11811..ba234fd 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -7,13 +7,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 +21,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 Metrics/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 Metrics/LineLength user: 'root', logoutput: 'on_failure') } @@ -38,7 +37,6 @@ describe 'apt::ppa' do operatingsystem: 'Ubuntu', osfamily: 'Debian', lsbdistid: 'Ubuntu', - puppetversion: Puppet.version, } end @@ -46,8 +44,8 @@ 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 Metrics/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 Metrics/LineLength user: 'root', logoutput: 'on_failure') } @@ -65,13 +63,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 @@ -80,54 +77,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 Metrics/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 Metrics/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 @@ -137,13 +94,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 @@ -157,14 +113,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 Metrics/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 Metrics/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 @@ -182,7 +138,6 @@ describe 'apt::ppa' do operatingsystem: 'Ubuntu', lsbdistid: 'Ubuntu', osfamily: 'Debian', - puppetversion: Puppet.version, } end let :params do @@ -198,8 +153,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 Metrics/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 Metrics/LineLength user: 'root', logoutput: 'on_failure') } @@ -219,7 +174,6 @@ describe 'apt::ppa' do operatingsystem: 'Ubuntu', lsbdistid: 'Ubuntu', osfamily: 'Debian', - puppetversion: Puppet.version, } end let :params do @@ -233,8 +187,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 Metrics/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 Metrics/LineLength user: 'root', logoutput: 'on_failure') } @@ -254,7 +208,6 @@ describe 'apt::ppa' do operatingsystem: 'Ubuntu', lsbdistid: 'Ubuntu', osfamily: 'Debian', - puppetversion: Puppet.version, } end let :params do @@ -268,8 +221,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 Metrics/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 Metrics/LineLength user: 'root', logoutput: 'on_failure') } @@ -289,7 +242,6 @@ describe 'apt::ppa' do operatingsystem: 'Ubuntu', lsbdistid: 'Ubuntu', osfamily: 'Debian', - puppetversion: Puppet.version, } end let :params do @@ -303,8 +255,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 Metrics/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 Metrics/LineLength user: 'root', logoutput: 'on_failure') } @@ -322,7 +274,6 @@ describe 'apt::ppa' do operatingsystem: 'Ubuntu', lsbdistid: 'Ubuntu', osfamily: 'Debian', - puppetversion: Puppet.version, } end let(:title) { 'ppa:user/foo' } @@ -337,7 +288,7 @@ describe 'apt::ppa' do } end - context 'validation' do + context 'with validation' do describe 'no release' do let :facts do { @@ -347,7 +298,6 @@ describe 'apt::ppa' do lsbdistid: 'Ubuntu', osfamily: 'Debian', lsbdistcodeanme: nil, - puppetversion: Puppet.version, } end let(:title) { 'ppa:user/foo' } @@ -366,7 +316,6 @@ describe 'apt::ppa' do operatingsystem: 'Debian', lsbdistid: 'debian', osfamily: 'Debian', - puppetversion: Puppet.version, } end let(:title) { 'ppa:user/foo' }