summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Higgins <pete@peterhiggins.org>2020-06-26 13:38:57 -0700
committerPete Higgins <pete@peterhiggins.org>2020-06-26 13:39:52 -0700
commit157e084cef71c31af86d751ccd55410fa3611885 (patch)
tree55036e8f45c49307cf79dbab407650899658a4aa
parente23fe89f57148cbfb71a1f84b470c4b92b2ee0a7 (diff)
downloadchef-fix-umask-test-on-windows.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.rb2
-rw-r--r--spec/unit/resource_spec.rb33
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