diff options
author | Tim Smith <tsmith@chef.io> | 2020-06-28 19:15:32 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-28 19:15:32 -0700 |
commit | 6a05076d838fc407e3c31003e538d5118558587b (patch) | |
tree | 28134a9a4b57c09aa2781dbcc688be478384c847 | |
parent | a11936dff401b59cd2eddd2cf48092e0b504f6e8 (diff) | |
parent | 157e084cef71c31af86d751ccd55410fa3611885 (diff) | |
download | chef-6a05076d838fc407e3c31003e538d5118558587b.tar.gz |
Merge pull request #10077 from chef/fix-umask-test-on-windows
Update tests and docs for umask on Windows.
-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 |