diff options
author | Tim Smith <tsmith84@gmail.com> | 2020-08-26 13:38:43 -0700 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-08-26 13:38:43 -0700 |
commit | 43fec1b8be629e7e3db9b97e3aab90165f353355 (patch) | |
tree | bcd1bf3d0dd9f0609177ee63c1f63b750d88ae12 /spec | |
parent | 2aa82ff20a0adad63effc750960f495a3c309a82 (diff) | |
download | chef-43fec1b8be629e7e3db9b97e3aab90165f353355.tar.gz |
Improve input handling and validation in chef_client_launchdbetter_launchd_properties
Validate correct nice ranges
Make sure interval is a positive value
Allow nice and interval to be input as Strings
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/resource/chef_client_launchd.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/unit/resource/chef_client_launchd.rb b/spec/unit/resource/chef_client_launchd.rb index 6ec7889c79..4d07471ed5 100644 --- a/spec/unit/resource/chef_client_launchd.rb +++ b/spec/unit/resource/chef_client_launchd.rb @@ -38,6 +38,28 @@ describe Chef::Resource::ChefClientLaunchd do expect { resource.action :disable }.not_to raise_error end + it "raises an error if interval is not a positive number" do + expect { resource.interval("-10") }.to raise_error(Chef::Exceptions::ValidationFailed) + end + + it "coerces interval to an Integer" do + resource.interval "10" + expect(resource.interval).to eql(10) + 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 + + it "coerces nice to an Integer" do + resource.nice "10" + expect(resource.nice).to eql(10) + end + describe "#all_daemon_options" do it "returns log and config flags if by default" do expect(provider.all_daemon_options).to eql( |