diff options
author | Tim Smith <tsmith@chef.io> | 2018-06-11 10:58:51 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-11 10:58:51 -0700 |
commit | e30ca37a012ac501e1bf725fdbc38b9c510c0408 (patch) | |
tree | d09f3e3b2a4856d9f90de8741fb33fb0c752bd9a | |
parent | 3777f77bc0ccace0a7f11015e3fb4c7de4a43823 (diff) | |
parent | 7cdf9f35f6f40b26ec2f408f31e5e43d150b80a1 (diff) | |
download | chef-e30ca37a012ac501e1bf725fdbc38b9c510c0408.tar.gz |
Merge pull request #7351 from josh-barker/bug/why-run-windows-package-local-file
Add whyrun message when installing a local file on Windows
-rw-r--r-- | lib/chef/provider/package/windows.rb | 1 | ||||
-rw-r--r-- | spec/unit/provider/package/windows_spec.rb | 13 |
2 files changed, 11 insertions, 3 deletions
diff --git a/lib/chef/provider/package/windows.rb b/lib/chef/provider/package/windows.rb index 8958bff068..05f865d4e4 100644 --- a/lib/chef/provider/package/windows.rb +++ b/lib/chef/provider/package/windows.rb @@ -44,6 +44,7 @@ class Chef requirements.assert(:install) do |a| a.assertion { ::File.exist?(new_resource.source) } a.failure_message Chef::Exceptions::Package, "Source for package #{new_resource.name} does not exist" + a.whyrun "Assuming source file #{new_resource.source} would have been created." end end end diff --git a/spec/unit/provider/package/windows_spec.rb b/spec/unit/provider/package/windows_spec.rb index 0f4fd465c8..aed0ca88be 100644 --- a/spec/unit/provider/package/windows_spec.rb +++ b/spec/unit/provider/package/windows_spec.rb @@ -398,13 +398,20 @@ describe Chef::Provider::Package::Windows, :windows_only do context "a missing local file is given" do let(:resource_source) { "C:/a_missing_file.exe" } let(:installer_type) { nil } - - it "raises a Package error" do + before do allow(::File).to receive(:exist?).with(provider.new_resource.source).and_return(false) - provider.load_current_resource + end + + it "raises a Package error" do expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package) end + + it "why_run mode doesn't raise an error" do + Chef::Config[:why_run] = true + expect { provider.run_action(:install) }.not_to raise_error + Chef::Config[:why_run] = false + end end end |