diff options
author | Pete Higgins <pete@peterhiggins.org> | 2020-06-26 13:38:57 -0700 |
---|---|---|
committer | Pete Higgins <pete@peterhiggins.org> | 2020-06-26 13:39:52 -0700 |
commit | 157e084cef71c31af86d751ccd55410fa3611885 (patch) | |
tree | 55036e8f45c49307cf79dbab407650899658a4aa | |
parent | e23fe89f57148cbfb71a1f84b470c4b92b2ee0a7 (diff) | |
download | chef-157e084cef71c31af86d751ccd55410fa3611885.tar.gz |
Update tests and docs for umask on Windows.fix-umask-test-on-windows
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
-rw-r--r-- | lib/chef/resource.rb | 2 | ||||
-rw-r--r-- | spec/unit/resource_spec.rb | 33 |
2 files changed, 26 insertions, 9 deletions
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb index 37e964a243..bd6757c6f7 100644 --- a/lib/chef/resource.rb +++ b/lib/chef/resource.rb @@ -460,7 +460,7 @@ class Chef property :umask, String, desired_state: false, introduced: "16.2", - description: "Set a umask to be used for the duration of converging the resource. Defaults to `nil`, which means to use the system umask." + description: "Set a umask to be used for the duration of converging the resource. Defaults to `nil`, which means to use the system umask. Unsupported on Windows because Windows lacks a direct equivalent to UNIX's umask." # The time it took (in seconds) to run the most recently-run action. Not # cumulative across actions. This is set to 0 as soon as a new action starts diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb index 5181414215..7a19e0e8e1 100644 --- a/spec/unit/resource_spec.rb +++ b/spec/unit/resource_spec.rb @@ -1255,19 +1255,36 @@ describe Chef::Resource do expect(block_value).to eq(original_umask) end - it "changes the umask in the block to the set value" do - resource.umask = "0123" + if windows? + it "is a no-op on Windows" do + resource.umask = "0123" - block_value = nil + block_value = nil - resource.with_umask do - block_value = ::File.umask + resource.with_umask do + block_value = ::File.umask + end + + # Format the returned value so a potential error message is easier to understand. + actual_value = block_value.to_s(8).rjust(4, "0") + + expect(actual_value).to eq("0000") end + else + it "changes the umask in the block to the set value" do + resource.umask = "0123" + + block_value = nil - # Format the returned value so a potential error message is easier to understand. - actual_value = block_value.to_s(8).rjust(4, "0") + resource.with_umask do + block_value = ::File.umask + end - expect(actual_value).to eq("0123") + # Format the returned value so a potential error message is easier to understand. + actual_value = block_value.to_s(8).rjust(4, "0") + + expect(actual_value).to eq("0123") + end end it "resets the umask afterwards" do |