diff options
author | Tim Smith <tsmith@chef.io> | 2020-02-27 10:19:17 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-27 10:19:17 -0800 |
commit | 87b0c1d8defc8873a99a710fbec2e44d26d6d246 (patch) | |
tree | 484437827bf7899adf877a576ab3524cf4961403 | |
parent | da8c141b35db7d055f81ebf1d45134f096a0971e (diff) | |
parent | ab720d3c5272c765d6afe11257f6359c545d243a (diff) | |
download | chef-87b0c1d8defc8873a99a710fbec2e44d26d6d246.tar.gz |
Merge pull request #9396 from chef/windows_package_3010
Accept exit code 3010 as valid in windows_package
-rw-r--r-- | lib/chef/resource/windows_package.rb | 6 | ||||
-rw-r--r-- | spec/unit/provider/package/windows/exe_spec.rb | 2 | ||||
-rw-r--r-- | spec/unit/resource/windows_package_spec.rb | 6 |
3 files changed, 10 insertions, 4 deletions
diff --git a/lib/chef/resource/windows_package.rb b/lib/chef/resource/windows_package.rb index 3402cb0792..9fac482f9b 100644 --- a/lib/chef/resource/windows_package.rb +++ b/lib/chef/resource/windows_package.rb @@ -55,9 +55,11 @@ class Chef description: "The amount of time (in seconds) to wait before timing out." # In the past we accepted return code 127 for an unknown reason and 42 because of a bug - property :returns, [ String, Integer, Array ], default: [ 0 ], + # we accept 3010 which means success, but a reboot is necessary + property :returns, [ String, Integer, Array ], default: [ 0, 3010 ], desired_state: false, - description: "A comma-delimited list of return codes that indicate the success or failure of the package command that was run." + description: "A comma-delimited list of return codes that indicate the success or failure of the package command that was run.", + default_description: "0 (success) and 3010 (success where a reboot is necessary)" property :source, String, coerce: (proc do |s| diff --git a/spec/unit/provider/package/windows/exe_spec.rb b/spec/unit/provider/package/windows/exe_spec.rb index 2ed4c03905..afceaabd55 100644 --- a/spec/unit/provider/package/windows/exe_spec.rb +++ b/spec/unit/provider/package/windows/exe_spec.rb @@ -126,7 +126,7 @@ describe Chef::Provider::Package::Windows::Exe do it "removes installed package and quotes uninstall string" do new_resource.timeout = 300 allow(::File).to receive(:exist?).with("uninst_dir/uninst_file").and_return(true) - expect(provider).to receive(:shell_out!).with(%r{start \"\" /wait \"uninst_dir/uninst_file\" /S /NCRC & exit %%%%ERRORLEVEL%%%%}, default_env: false, timeout: 300, returns: [0]) + expect(provider).to receive(:shell_out!).with(%r{start \"\" /wait \"uninst_dir/uninst_file\" /S /NCRC & exit %%%%ERRORLEVEL%%%%}, default_env: false, timeout: 300, returns: [0, 3010]) provider.remove_package end end diff --git a/spec/unit/resource/windows_package_spec.rb b/spec/unit/resource/windows_package_spec.rb index a0f746393d..af38942877 100644 --- a/spec/unit/resource/windows_package_spec.rb +++ b/spec/unit/resource/windows_package_spec.rb @@ -1,6 +1,6 @@ # # Author:: Bryan McLellan <btm@loftninjas.org> -# Copyright:: Copyright 2014-2019, Chef Software, Inc. +# Copyright:: Copyright 2014-2020, Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -89,6 +89,10 @@ describe Chef::Resource::WindowsPackage, "initialize" do expect(resource.source).to eql "c:\\frost.msi" end + it "defaults returns to [0, 3010]" do + expect(resource.returns).to eq([0, 3010]) + end + it "defaults source to the resource name" do # it's a little late to stub out File.absolute_path expect(resource.source).to include("solitaire.msi") |