93567aef4a
when updating or installing newer packages with apt::force and you have changed previous configuration files aptitude or apt-get will prompt what to do. You can suppress that by pre-define the action with cfg_files parameter (new, old or unchanged and its backward compatible if not defined). With a second optional parameter cfg_missing you can force your provider to install missing configuration files as well. Signed-off-by: Martin Seener <martin@seener.de> apt::force: Changed selectors used in force.pp to case statements; refs #module-1306 Signed-off-by: Martin Seener <martin@seener.de> apt::force: rspec: fixed the failing tests and added validate_re for cfg_files and validate_bool for cfg_missing. Also removed default values for both case statements and only allow pre-defined values or true/false. Furthermore enhanced the README refs #module-1306 Was able to fix the failing rspec tests for the patch. Thanks to Morgan Haskel. Signed-off-by: Martin Seener <martin@seener.de> Despite the puppetlabs-stdlib documentation says validation_re supports 3 arguments the tests failed telling that only 2 are supported. Fixed this by removing the 3 optional argument; refs #modules-1306 Signed-off-by: Martin Seener <martin.seener@barzahlen.de> apt::force: updated readme refs #module-1306 Signed-off-by: Martin Seener <martin@seener.de>
102 líneas
3,4 KiB
Ruby
102 líneas
3,4 KiB
Ruby
require 'spec_helper'
|
|
describe 'apt::force', :type => :define do
|
|
let(:facts) { { :lsbdistid => 'Debian' } }
|
|
let :pre_condition do
|
|
'include apt::params'
|
|
end
|
|
|
|
let :title do
|
|
'my_package'
|
|
end
|
|
|
|
let :default_params do
|
|
{
|
|
:release => false,
|
|
:version => false,
|
|
:cfg_files => 'none',
|
|
:cfg_missing => false,
|
|
}
|
|
end
|
|
|
|
describe "when using default parameters" do
|
|
it { should contain_exec("/usr/bin/apt-get -y install #{title}").with(
|
|
:unless => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'",
|
|
:logoutput => 'on_failure',
|
|
:timeout => '300'
|
|
) }
|
|
end
|
|
|
|
describe "when specifying release parameter" do
|
|
let :params do
|
|
default_params.merge(:release => 'testing')
|
|
end
|
|
it { should contain_exec("/usr/bin/apt-get -y -t #{params[:release]} install #{title}").with(
|
|
:unless => "/usr/bin/test \$(/usr/bin/apt-cache policy -t #{params[:release]} #{title} | /bin/grep -E 'Installed|Candidate' | /usr/bin/uniq -s 14 | /usr/bin/wc -l) -eq 1"
|
|
) }
|
|
end
|
|
|
|
describe "when specifying version parameter" do
|
|
let :params do
|
|
default_params.merge(:version => '1')
|
|
end
|
|
it { should contain_exec("/usr/bin/apt-get -y install #{title}=#{params[:version]}").with(
|
|
:unless => "/usr/bin/dpkg -s #{title} | grep -q 'Version: #{params[:version]}'"
|
|
) }
|
|
end
|
|
|
|
describe "when specifying cfg_files parameter" do
|
|
let :params do
|
|
default_params.merge(:cfg_files => 'unchanged')
|
|
end
|
|
it { should contain_exec('/usr/bin/apt-get -y -o Dpkg::Options::="--force-confdef" install my_package').with(
|
|
:unless => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'"
|
|
) }
|
|
end
|
|
|
|
describe "when specifying cfg_missing parameter" do
|
|
let :params do
|
|
default_params.merge(:cfg_missing => true)
|
|
end
|
|
it { should contain_exec('/usr/bin/apt-get -y -o Dpkg::Options::="--force-confmiss" install my_package').with(
|
|
:unless => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'"
|
|
) }
|
|
end
|
|
|
|
describe "when specifying cfg_files and cfg_missing parameter" do
|
|
let :params do
|
|
default_params.merge(
|
|
:cfg_files => 'unchanged',
|
|
:cfg_missing => true
|
|
)
|
|
end
|
|
it { should contain_exec('/usr/bin/apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confmiss" install my_package').with(
|
|
:unless => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'"
|
|
) }
|
|
end
|
|
|
|
describe "when specifying release and version parameters" do
|
|
let :params do
|
|
default_params.merge(
|
|
:release => 'testing',
|
|
:version => '1'
|
|
)
|
|
end
|
|
it { should contain_exec("/usr/bin/apt-get -y -t #{params[:release]} install #{title}=1").with(
|
|
:unless => "/usr/bin/apt-cache policy -t #{params[:release]} #{title} | /bin/grep -q 'Installed: #{params[:version]}'"
|
|
) }
|
|
end
|
|
|
|
describe "when specifying release, version, cfg_files and cfg_missing parameters" do
|
|
let :params do
|
|
default_params.merge(
|
|
:release => 'testing',
|
|
:version => '1',
|
|
:cfg_files => 'unchanged',
|
|
:cfg_missing => true
|
|
)
|
|
end
|
|
it { should contain_exec('/usr/bin/apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confmiss" -t testing install my_package=1').with(
|
|
:unless => "/usr/bin/apt-cache policy -t #{params[:release]} #{title} | /bin/grep -q 'Installed: #{params[:version]}'"
|
|
) }
|
|
end
|
|
end
|