This switches us to doing a test -s
instead of checking for the
files existence as add-apt-repository --remove leaves a 0 byte file behind instead of deleting everything properly.
This commit is contained in:
parent
bb5fcad152
commit
2f9c16a273
3 changed files with 27 additions and 6 deletions
|
@ -42,7 +42,7 @@ define apt::ppa(
|
|||
exec { "add-apt-repository-${name}":
|
||||
environment => $proxy_env,
|
||||
command => "/usr/bin/add-apt-repository ${options} ${name}",
|
||||
creates => "${sources_list_d}/${sources_list_d_filename}",
|
||||
onlyif => "/usr/bin/test -s ${sources_list_d}/${sources_list_d_filename}",
|
||||
logoutput => 'on_failure',
|
||||
notify => Exec['apt_update'],
|
||||
require => [
|
||||
|
|
|
@ -45,7 +45,7 @@ describe 'apt::ppa', :type => :define do
|
|||
|
||||
it { should contain_exec("add-apt-repository-#{t}").with(
|
||||
'command' => "/usr/bin/add-apt-repository #{options} #{t}",
|
||||
'creates' => "/etc/apt/sources.list.d/#{filename}",
|
||||
'onlyif' => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}",
|
||||
'require' => ["File[/etc/apt/sources.list.d]", "Package[#{package}]"],
|
||||
'notify' => "Exec[apt_update]"
|
||||
)
|
||||
|
@ -74,7 +74,7 @@ describe 'apt::ppa', :type => :define do
|
|||
it { should contain_exec("add-apt-repository-#{title}").with(
|
||||
'environment' => [],
|
||||
'command' => "/usr/bin/add-apt-repository #{options} #{title}",
|
||||
'creates' => "/etc/apt/sources.list.d/#{filename}",
|
||||
'onlyif' => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}",
|
||||
'require' => ["File[/etc/apt/sources.list.d]", "Package[#{package}]"],
|
||||
'notify' => "Exec[apt_update]"
|
||||
)
|
||||
|
@ -100,7 +100,7 @@ describe 'apt::ppa', :type => :define do
|
|||
"https_proxy=http://user:pass@proxy:8080",
|
||||
],
|
||||
'command' => "/usr/bin/add-apt-repository #{options} #{title}",
|
||||
'creates' => "/etc/apt/sources.list.d/#{filename}",
|
||||
'onlyif' => "/usr/bin/test -s /etc/apt/sources.list.d/#{filename}",
|
||||
'require' => ["File[/etc/apt/sources.list.d]", "Package[#{package}]"],
|
||||
'notify' => "Exec[apt_update]"
|
||||
)
|
||||
|
|
|
@ -5,10 +5,11 @@ describe 'apt::ppa' do
|
|||
context 'reset' do
|
||||
it 'removes ppa' do
|
||||
shell('rm /etc/apt/sources.list.d/drizzle-developers-ppa*')
|
||||
shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*')
|
||||
end
|
||||
end
|
||||
|
||||
context 'apt::ppa' do
|
||||
context 'adding a ppa that doesnt exist' do
|
||||
it 'should work with no errors' do
|
||||
pp = <<-EOS
|
||||
include '::apt'
|
||||
|
@ -29,9 +30,29 @@ describe 'apt::ppa' do
|
|||
end
|
||||
end
|
||||
|
||||
context 'readding a removed ppa.' do
|
||||
it 'setup' do
|
||||
shell('add-apt-repository -y ppa:raravena80/collectd5')
|
||||
# This leaves a blank file
|
||||
shell('add-apt-repository --remove ppa:raravena80/collectd5')
|
||||
end
|
||||
|
||||
it 'should readd it successfully' do
|
||||
pp = <<-EOS
|
||||
include '::apt'
|
||||
apt::ppa { 'ppa:raravena80/collectd5': }
|
||||
EOS
|
||||
|
||||
puppet_apply(pp) do |r|
|
||||
r.exit_code.should_not == 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'reset' do
|
||||
it 'removes ppa' do
|
||||
it 'removes added ppas' do
|
||||
shell('rm /etc/apt/sources.list.d/drizzle-developers-ppa*')
|
||||
shell('rm /etc/apt/sources.list.d/raravena80-collectd5-*')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue