summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-09-05 22:35:53 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-09-05 22:35:53 +0000
commitfa16a92ff96d37d6b0d443536218d9d46d56eadd (patch)
treed40ecfa1e23c9a258e837a628f0d542c4637af86
parente28250dc1d30cf9e9c13e157143e140b402c967e (diff)
downloadpuppet-fa16a92ff96d37d6b0d443536218d9d46d56eadd.tar.gz
puppet-fa16a92ff96d37d6b0d443536218d9d46d56eadd.tar.xz
puppet-fa16a92ff96d37d6b0d443536218d9d46d56eadd.zip
Fixing small bug in cron where removed fields are not deleted from the file
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1565 980ebf18-57e1-0310-9a29-db15c13687c0
-rwxr-xr-xlib/puppet/filetype.rb6
-rwxr-xr-xlib/puppet/type/cron.rb3
-rwxr-xr-xtest/types/cron.rb24
3 files changed, 23 insertions, 10 deletions
diff --git a/lib/puppet/filetype.rb b/lib/puppet/filetype.rb
index a5dc6a115..03bf70838 100755
--- a/lib/puppet/filetype.rb
+++ b/lib/puppet/filetype.rb
@@ -153,7 +153,11 @@ module Puppet
# Remove a specific @path's cron tab.
def remove
- %x{#{cmdbase()} -r 2>/dev/null}
+ if Facter.value("operatingsystem") == "FreeBSD"
+ %x{/bin/echo yes | #{cmdbase()} -r 2>/dev/null}
+ else
+ %x{#{cmdbase()} -r 2>/dev/null}
+ end
end
# Overwrite a specific @path's cron tab; must be passed the @path name
diff --git a/lib/puppet/type/cron.rb b/lib/puppet/type/cron.rb
index 03ac24d29..cabe52a40 100755
--- a/lib/puppet/type/cron.rb
+++ b/lib/puppet/type/cron.rb
@@ -782,7 +782,8 @@ module Puppet
if @states.include?(name)
ret = @states[name].should_to_s
- if ret == :absent or ret.nil?
+ #if ret == :absent or ret.nil?
+ if ret.nil?
ret = @states[name].is_to_s
end
diff --git a/test/types/cron.rb b/test/types/cron.rb
index caada9f91..ed822ab4b 100755
--- a/test/types/cron.rb
+++ b/test/types/cron.rb
@@ -57,18 +57,25 @@ class TestCron < Test::Unit::TestCase
end
# Create a cron job with all fields filled in.
- def mkcron(name)
+ def mkcron(name, addargs = true)
cron = nil
- assert_nothing_raised {
- cron = @crontype.create(
- :command => "date > %s/crontest%s" % [tmpdir(), name],
+ command = "date > %s/crontest%s" % [tmpdir(), name]
+ args = nil
+ if addargs
+ args = {
+ :command => command,
:name => name,
:user => @me,
:minute => rand(59),
:month => "1",
:monthday => "1",
:hour => "1"
- )
+ }
+ else
+ args = {:command => command, :name => name}
+ end
+ assert_nothing_raised {
+ cron = @crontype.create(args)
}
return cron
@@ -554,16 +561,16 @@ class TestCron < Test::Unit::TestCase
end
def test_value
- cron = mkcron("valuetesting")
+ cron = mkcron("valuetesting", false)
# First, test the normal states
[:minute, :hour, :month].each do |param|
+ cron.newstate(param)
state = cron.state(param)
assert(state, "Did not get %s state" % param)
assert_nothing_raised {
- state.should = :absent
state.is = :absent
}
@@ -602,10 +609,11 @@ class TestCron < Test::Unit::TestCase
end
# Now make sure that :command works correctly
+ cron.delete(:command)
+ cron.newstate(:command)
state = cron.state(:command)
assert_nothing_raised {
- state.should = :absent
state.is = :absent
}