From: Dan Bode Date: Fri, 13 Jan 2012 19:02:42 +0000 (-0800) Subject: (#11413) Add spec test for apt::force to verify changes to unless X-Git-Tag: 0.0.1~17^2 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=f71db53130c28e9fc6fd7468df6800b15ad7676e;p=puppet-modules%2Fpuppetlabs-apt.git (#11413) Add spec test for apt::force to verify changes to unless In the Previous commits, the query being done by the apt::force install command was not strict enough and could lead to false positives. These queries represented by the unless parameter have been resolved in another commit. This commit accompanies that commit and adds basic unit tests to correspond to the changes. --- diff --git a/spec/defines/force_spec.rb b/spec/defines/force_spec.rb new file mode 100644 index 0000000..d040dc9 --- /dev/null +++ b/spec/defines/force_spec.rb @@ -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