diff options
author | Tim Smith <tsmith84@gmail.com> | 2020-03-23 12:42:38 -0700 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-03-23 12:57:39 -0700 |
commit | fdb5f1ecae566acb83500cd47db91e28e635bfcf (patch) | |
tree | c81700476f02ef0899267ad003fa45b99af27a2b | |
parent | 25cbdcb2c9d3340a58a398e0ed50eb30441d6119 (diff) | |
download | chef-fdb5f1ecae566acb83500cd47db91e28e635bfcf.tar.gz |
Fix some invalid functional tests
This was setting a totally invalid cron timing:
```
# Chef Name: something
@hourly * * * * /bin/true
```
This should be:
```
# Chef Name: something
@hourly /bin/true
```
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | spec/functional/resource/cron_spec.rb | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/spec/functional/resource/cron_spec.rb b/spec/functional/resource/cron_spec.rb index 16b0d2645c..0b35559cae 100644 --- a/spec/functional/resource/cron_spec.rb +++ b/spec/functional/resource/cron_spec.rb @@ -1,7 +1,7 @@ # encoding: UTF-8 # # Author:: Kaustubh Deorukhkar (<kaustubh@clogeny.com>) -# Copyright:: Copyright 2013-2017, Chef Software Inc. +# Copyright:: Copyright 2013-2020, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -55,13 +55,8 @@ describe Chef::Resource::Cron, :requires_root, :unix_only do # Actual tests let(:new_resource) do new_resource = Chef::Resource::Cron.new("Chef functional test cron", run_context) - new_resource.user "root" - # @hourly is not supported on solaris, aix - if ohai[:platform] == "solaris2" || ohai[:platform] == "aix" - new_resource.minute "0 * * * *" - else - new_resource.minute "@hourly" - end + new_resource.user "root" + new_resource.minute "0" new_resource.hour "" new_resource.day "" new_resource.month "" @@ -106,7 +101,7 @@ describe Chef::Resource::Cron, :requires_root, :unix_only do exclude_solaris = %w{solaris opensolaris solaris2 omnios}.include?(ohai[:platform]) describe "create action with various attributes", external: exclude_solaris do - def create_and_validate_with_attribute(resource, attribute, value) + def create_and_validate_with_property(resource, attribute, value) if ohai[:platform] == "aix" expect { resource.run_action(:create) }.to raise_error(Chef::Exceptions::Cron, /Aix cron entry does not support environment variables. Please set them in script and use script in cron./) else @@ -130,28 +125,28 @@ describe Chef::Resource::Cron, :requires_root, :unix_only do it "should create a crontab entry for mailto attribute" do new_resource.mailto "cheftest@example.com" - create_and_validate_with_attribute(new_resource, "mailto", "cheftest@example.com") + create_and_validate_with_property(new_resource, "mailto", "cheftest@example.com") end it "should create a crontab entry for path attribute" do new_resource.path "/usr/local/bin" - create_and_validate_with_attribute(new_resource, "path", "/usr/local/bin") + create_and_validate_with_property(new_resource, "path", "/usr/local/bin") end it "should create a crontab entry for shell attribute" do new_resource.shell "/bin/bash" - create_and_validate_with_attribute(new_resource, "shell", "/bin/bash") + create_and_validate_with_property(new_resource, "shell", "/bin/bash") end it "should create a crontab entry for home attribute" do new_resource.home "/home/opscode" - create_and_validate_with_attribute(new_resource, "home", "/home/opscode") + create_and_validate_with_property(new_resource, "home", "/home/opscode") end %i{ home mailto path shell }.each do |attr| it "supports an empty string for #{attr} attribute" do new_resource.send(attr, "") - create_and_validate_with_attribute(new_resource, attr.to_s, "") + create_and_validate_with_property(new_resource, attr.to_s, "") end end end |