Merge pull request #11 from bodepd/11413_apt_force_query_fix
11413 apt force query fix
This commit is contained in:
commit
30b6748f02
2 changed files with 25 additions and 2 deletions
|
@ -8,8 +8,8 @@ define apt::force(
|
|||
|
||||
exec { "/usr/bin/aptitude -y -t ${release} install ${name}":
|
||||
unless => $version ? {
|
||||
false => "/usr/bin/dpkg -l | grep ${name}",
|
||||
default => "/usr/bin/dpkg -l | grep ${name} | grep ${version}"
|
||||
false => "/usr/bin/dpkg -s ${name} | grep -q 'Status: install'",
|
||||
default => "/usr/bin/dpkg -s ${name} | grep -q 'Version: ${version}'"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
23
spec/defines/force_spec.rb
Normal file
23
spec/defines/force_spec.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
require 'spec_helper'
|
||||
describe 'apt::force', :type => :define do
|
||||
|
||||
let :title do
|
||||
'my_package'
|
||||
end
|
||||
|
||||
[false, '1'].each do |version|
|
||||
describe "with version: #{version}" do
|
||||
let :params do
|
||||
{:version => version, :release => 'testing'}
|
||||
end
|
||||
let :unless_query do
|
||||
base_command = "/usr/bin/dpkg -s #{title} | grep -q "
|
||||
base_command + (version ? "'Version: #{params[:version]}'" : "'Status: install'")
|
||||
end
|
||||
let :exec_title do
|
||||
"/usr/bin/aptitude -y -t #{params[:release]} install #{title}"
|
||||
end
|
||||
it { should contain_exec(exec_title).with_unless(unless_query) }
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue