X-Git-Url: https://review.fuel-infra.org/gitweb?a=blobdiff_plain;f=spec%2Fdefines%2Fppa_spec.rb;h=fa893b6997272429aac97883c1cd48328edbd368;hb=e99d83c2d6bdd45a9111eab0306da105c1f2acca;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..fa893b6 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -7,9 +7,9 @@ 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', @@ -22,8 +22,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') } @@ -46,8 +46,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,9 +65,9 @@ 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', @@ -80,54 +80,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,9 +97,9 @@ 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', @@ -157,14 +117,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 @@ -198,8 +158,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') } @@ -233,8 +193,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') } @@ -268,8 +228,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') } @@ -303,8 +263,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') } @@ -337,7 +297,7 @@ describe 'apt::ppa' do } end - context 'validation' do + context 'with validation' do describe 'no release' do let :facts do {