summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2020-08-26 14:49:20 -0700
committerGitHub <noreply@github.com>2020-08-26 14:49:20 -0700
commit2a7a35a22073d86ef830767f08e431b906eba328 (patch)
tree583a0a14641bcebf777124611081c89ffb9fc974
parentff8a59dab5091968171c69297c315a6943ea28ed (diff)
parent92001258bd817b532b915ac53ac16f4762bd643e (diff)
downloadchef-2a7a35a22073d86ef830767f08e431b906eba328.tar.gz
Merge pull request #10359 from chef/launchd_nice
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/resource/launchd.rb3
-rw-r--r--spec/unit/resource/launchd_spec.rb8
2 files changed, 10 insertions, 1 deletions
diff --git a/lib/chef/resource/launchd.rb b/lib/chef/resource/launchd.rb
index 70ff7b8974..a6125f7981 100644
--- a/lib/chef/resource/launchd.rb
+++ b/lib/chef/resource/launchd.rb
@@ -187,7 +187,8 @@ class Chef
description: "Specify services to be registered with the bootstrap subsystem."
property :nice, Integer,
- description: "The program scheduling priority value in the range -20 to 20."
+ description: "The program scheduling priority value in the range -20 to 19.",
+ callbacks: { "should be a Integer between -20 and 19" => proc { |v| v >= -20 && v <= 19 } }
property :on_demand, [ TrueClass, FalseClass ],
description: "Keep a job alive. Only applies to macOS version 10.4 (and earlier); use keep_alive instead for newer versions."
diff --git a/spec/unit/resource/launchd_spec.rb b/spec/unit/resource/launchd_spec.rb
index bf3fd39952..62f5ad0b92 100644
--- a/spec/unit/resource/launchd_spec.rb
+++ b/spec/unit/resource/launchd_spec.rb
@@ -37,4 +37,12 @@ describe Chef::Resource::Launchd do
expect { resource.action :enable }.not_to raise_error
expect { resource.action :restart }.not_to raise_error
end
+
+ it "raises an error if nice is less than -20" do
+ expect { resource.nice(-21) }.to raise_error(Chef::Exceptions::ValidationFailed)
+ end
+
+ it "raises an error if nice is greater than 19" do
+ expect { resource.nice(20) }.to raise_error(Chef::Exceptions::ValidationFailed)
+ end
end