diff options
author | Tim Smith <tsmith@chef.io> | 2020-08-26 15:02:06 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-26 15:02:06 -0700 |
commit | d3f88ab5ebdc7d053f9710334bb8245507452262 (patch) | |
tree | 96228bd25c0184a30ec12d107669201a987336b3 /spec | |
parent | 42b88ccc0d01d6f4d1a1a5a0c34dbcdbc58e512c (diff) | |
parent | b045f01d7e7ce619bb58025f067b9b1762ba8d9c (diff) | |
download | chef-d3f88ab5ebdc7d053f9710334bb8245507452262.tar.gz |
Merge pull request #10358 from chef/add_back_nice
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/resource/chef_client_cron_spec.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/unit/resource/chef_client_cron_spec.rb b/spec/unit/resource/chef_client_cron_spec.rb index b6b28329a9..00d12b82a8 100644 --- a/spec/unit/resource/chef_client_cron_spec.rb +++ b/spec/unit/resource/chef_client_cron_spec.rb @@ -38,6 +38,19 @@ describe Chef::Resource::ChefClientCron do expect { resource.splay("-10") }.to raise_error(Chef::Exceptions::ValidationFailed) 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 + it "builds a default value for chef_binary_path dist values" do expect(resource.chef_binary_path).to eql("/opt/chef/bin/chef-client") end @@ -131,5 +144,13 @@ describe Chef::Resource::ChefClientCron do "/bin/sleep 123; /opt/chef/bin/chef-client -c #{root_path} --chef-license accept -L /var/log/chef/client.log" ) end + + it "uses nice if set" do + allow(provider).to receive(:which).with("nice").and_return("/usr/bin/nice") + resource.nice(-15) + expect(provider.cron_command).to eql( + "/bin/sleep 123; /usr/bin/nice -n -15 /opt/chef/bin/chef-client -c /etc/chef/client.rb -L /var/log/chef/client.log" + ) + end end end |