diff options
author | Lamont Granquist <454857+lamont-granquist@users.noreply.github.com> | 2021-11-17 14:59:41 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-17 14:59:41 -0800 |
commit | ca06995f9b0f284c9e1096e8711041714b7f8714 (patch) | |
tree | 1a4b9343ec5dbe52ca0d1e829cf55cd25d41215c /spec | |
parent | c615ae3d594ee26746d547f3e25d299645e48190 (diff) | |
parent | 0371c9a580401ce9731e6d281f1565b7ef26a511 (diff) | |
download | chef-ca06995f9b0f284c9e1096e8711041714b7f8714.tar.gz |
Merge pull request #11970 from chef/snehal/fix_version_comparisons_on_upgrade
Diffstat (limited to 'spec')
-rw-r--r-- | spec/functional/resource/dpkg_package_spec.rb | 16 | ||||
-rw-r--r-- | spec/unit/resource/dpkg_package_spec.rb | 12 |
2 files changed, 28 insertions, 0 deletions
diff --git a/spec/functional/resource/dpkg_package_spec.rb b/spec/functional/resource/dpkg_package_spec.rb index 0a8202127c..280a5983e4 100644 --- a/spec/functional/resource/dpkg_package_spec.rb +++ b/spec/functional/resource/dpkg_package_spec.rb @@ -184,6 +184,22 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch: dpkg_package.run_action(action) expect(dpkg_package).to be_updated_by_last_action end + + it "should not allow downgrade a package" do + dpkg_package.allow_downgrade false + shell_out!("dpkg -i #{test1_1}") + set_dpkg_package_name test1_0 + dpkg_package.run_action(action) + expect(dpkg_package).not_to be_updated_by_last_action + end + + it "should allow downgrade a package" do + dpkg_package.allow_downgrade true + shell_out!("dpkg -i #{test1_1}") + set_dpkg_package_name test1_0 + dpkg_package.run_action(action) + expect(dpkg_package).to be_updated_by_last_action + end end shared_examples_for "common behavior for remove or purge" do diff --git a/spec/unit/resource/dpkg_package_spec.rb b/spec/unit/resource/dpkg_package_spec.rb index acd879597d..9ff752f11e 100644 --- a/spec/unit/resource/dpkg_package_spec.rb +++ b/spec/unit/resource/dpkg_package_spec.rb @@ -57,4 +57,16 @@ describe Chef::Resource::DpkgPackage, "initialize" do end end + describe Chef::Resource::DpkgPackage, "allow_downgrade" do + before(:each) do + @resource = Chef::Resource::DpkgPackage.new("fakey_fakerton") + end + + it "should allow you to specify whether allow_downgrade is true or false" do + expect { @resource.allow_downgrade true }.not_to raise_error + expect { @resource.allow_downgrade false }.not_to raise_error + expect { @resource.allow_downgrade "something" }.to raise_error(ArgumentError) + end + end + end |