diff options
author | Tor Magnus Rakvåg <tm@intility.no> | 2018-05-15 10:44:59 +0200 |
---|---|---|
committer | Tor Magnus Rakvåg <tm@intility.no> | 2018-05-15 10:44:59 +0200 |
commit | e726d30dd5c04953d4373abc500fc728e3bef744 (patch) | |
tree | 718cc76a6951af6af401fa398e8e48aee68aae9e | |
parent | e264b5a5f4d5e853340b915677e87b27cd16b272 (diff) | |
download | chef-e726d30dd5c04953d4373abc500fc728e3bef744.tar.gz |
skip_publisher_check tests
Signed-off-by: Tor Magnus Rakvåg <tm@intility.no>
-rw-r--r-- | spec/unit/provider/package/powershell_spec.rb | 13 | ||||
-rw-r--r-- | spec/unit/resource/powershell_package_spec.rb | 9 |
2 files changed, 22 insertions, 0 deletions
diff --git a/spec/unit/provider/package/powershell_spec.rb b/spec/unit/provider/package/powershell_spec.rb index 534b7b6b13..63f611ac23 100644 --- a/spec/unit/provider/package/powershell_spec.rb +++ b/spec/unit/provider/package/powershell_spec.rb @@ -304,6 +304,19 @@ describe Chef::Provider::Package::Powershell do expect(new_resource).to be_updated_by_last_action end + it "should install a package without the publisher check" do + provider.load_current_resource + new_resource.package_name(["xCertificate"]) + new_resource.version(nil) + new_resource.skip_publisher_check(true) + allow(provider).to receive(:powershell_out).with("( Find-Package 'xCertificate' -Force -ForceBootstrap ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_available) + allow(provider).to receive(:powershell_out).with("( Get-Package 'xCertificate' -Force -ForceBootstrap -SkipPublisherCheck ).Version", { :timeout => new_resource.timeout }).and_return(package_xcertificate_not_available) + allow(provider).to receive(:powershell_out).with("$PSVersionTable.PSVersion.Major").and_return(powershell_installed_version) + expect(provider).to receive(:powershell_out).with("( Install-Package 'xCertificate' -Force -ForceBootstrap -RequiredVersion 2.1.0.0 -SkipPublisherCheck ).Version", { :timeout => new_resource.timeout }) + provider.run_action(:install) + expect(new_resource).to be_updated_by_last_action + end + it "should install a single package when package name has space in between" do provider.load_current_resource new_resource.package_name(["7-Zip 16.02 (x64)"]) diff --git a/spec/unit/resource/powershell_package_spec.rb b/spec/unit/resource/powershell_package_spec.rb index a448d58d5a..9128654e80 100644 --- a/spec/unit/resource/powershell_package_spec.rb +++ b/spec/unit/resource/powershell_package_spec.rb @@ -72,4 +72,13 @@ describe Chef::Resource::PowershellPackage do resource.source("MyGallery") expect(resource.source).to eql("MyGallery") end + + it "the skip_publisher_check default is false" do + expect(resource.skip_publisher_check).to eql(false) + end + + it "the skip_publisher_check setter accepts booleans" do + resource.skip_publisher_check(true) + expect(resource.skip_publisher_check).to eql(true) + end end |