Fixing the rest of #705, except for the env stuff, which I was not able to reproduce.

git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2697 980ebf18-57e1-0310-9a29-db15c13687c0
This commit is contained in:
luke 2007-07-14 21:13:04 +00:00
Родитель 53c2f0a4c9
Коммит 60ef578150
4 изменённых файлов: 29 добавлений и 4 удалений

Просмотреть файл

@ -30,6 +30,7 @@ Puppet::Type.type(:cron).provide(:crontab,
}
crontab = record_line :crontab, :fields => %w{minute hour monthday month weekday command},
:match => %r{^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(.+)$},
:optional => %w{minute hour weekday month monthday}, :absent => "*"
class << crontab

Просмотреть файл

@ -301,8 +301,12 @@ Puppet::Type.newtype(:cron) do
end
def is_to_s(newvalue)
if newvalue
newvalue.join(",")
if newvalue
if newvalue.is_a?(Array)
newvalue.join(",")
else
newvalue
end
else
nil
end

Просмотреть файл

@ -168,8 +168,12 @@ module Puppet::Util::FileParsing
if match = regex.match(line)
fields = []
ret = {}
record.fields.zip(match.captures).each do |f, v|
ret[f] = v
record.fields.zip(match.captures).each do |field, value|
if value == record.absent
ret[field] = :absent
else
ret[field] = value
end
end
else
nil

Просмотреть файл

@ -487,6 +487,22 @@ class TestCron < Test::Unit::TestCase
"target did not default to user with crontab")
end
end
# #705 - make sure extra spaces don't screw things up
def test_spaces_in_command
string = "echo multiple spaces"
cron = @crontype.create(:name => "testing", :command => string)
assert_apply(cron)
cron.class.clear
cron = @crontype.create(:name => "testing", :command => string)
# Now make sure that it's correctly in sync
cron.provider.class.prefetch("testing" => cron)
properties = cron.retrieve
command, result = properties.find { |prop, value| prop.name == :command }
assert_equal(string, result, "Cron did not pick up extra spaces in command")
assert(command.insync?(string), "Command changed with multiple spaces")
end
end