2 describe 'apt::force', :type => :define do
3 let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
12 let :default_params do
17 :cfg_missing => false,
21 describe "when using default parameters" do
22 it { should contain_exec("/usr/bin/apt-get -y install #{title}").with(
23 :unless => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'",
24 :logoutput => 'on_failure',
29 describe "when specifying release parameter" do
31 default_params.merge(:release => 'testing')
33 it { should contain_exec("/usr/bin/apt-get -y -t #{params[:release]} install #{title}").with(
34 :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"
38 describe "when specifying version parameter" do
40 default_params.merge(:version => '1')
42 it { should contain_exec("/usr/bin/apt-get -y install #{title}=#{params[:version]}").with(
43 :unless => "/usr/bin/dpkg -s #{title} | grep -q 'Version: #{params[:version]}'"
47 describe "when specifying cfg_files parameter" do
49 default_params.merge(:cfg_files => 'unchanged')
51 it { should contain_exec('/usr/bin/apt-get -y -o Dpkg::Options::="--force-confdef" install my_package').with(
52 :unless => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'"
56 describe "when specifying cfg_missing parameter" do
58 default_params.merge(:cfg_missing => true)
60 it { should contain_exec('/usr/bin/apt-get -y -o Dpkg::Options::="--force-confmiss" install my_package').with(
61 :unless => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'"
65 describe "when specifying cfg_files and cfg_missing parameter" do
68 :cfg_files => 'unchanged',
72 it { should contain_exec('/usr/bin/apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confmiss" install my_package').with(
73 :unless => "/usr/bin/dpkg -s #{title} | grep -q 'Status: install'"
77 describe "when specifying release and version parameters" do
80 :release => 'testing',
84 it { should contain_exec("/usr/bin/apt-get -y -t #{params[:release]} install #{title}=1").with(
85 :unless => "/usr/bin/apt-cache policy -t #{params[:release]} #{title} | /bin/grep -q 'Installed: #{params[:version]}'"
89 describe "when specifying release, version, cfg_files and cfg_missing parameters" do
92 :release => 'testing',
94 :cfg_files => 'unchanged',
98 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(
99 :unless => "/usr/bin/apt-cache policy -t #{params[:release]} #{title} | /bin/grep -q 'Installed: #{params[:version]}'"