diff options
-rw-r--r-- | lib/puppet/type/pfile/target.rb | 6 | ||||
-rw-r--r-- | test/types/file.rb | 14 |
2 files changed, 20 insertions, 0 deletions
diff --git a/lib/puppet/type/pfile/target.rb b/lib/puppet/type/pfile/target.rb index 4a725d652..23fb30390 100644 --- a/lib/puppet/type/pfile/target.rb +++ b/lib/puppet/type/pfile/target.rb @@ -12,6 +12,12 @@ module Puppet # Anything else, basically newvalue(/./) do + if ! @parent.should(:ensure) + @parent[:ensure] = :link + elsif @parent.should(:ensure) != :link + raise Puppet::Error, + "You cannot specify a target unless 'ensure' is set to 'link'" + end if @parent.state(:ensure).insync? mklink() end diff --git a/test/types/file.rb b/test/types/file.rb index b87f1b928..d2c593c8b 100644 --- a/test/types/file.rb +++ b/test/types/file.rb @@ -1406,6 +1406,20 @@ class TestFile < Test::Unit::TestCase assert(FileTest.exists?(localfile), "File got purged") assert(! FileTest.exists?(randfile), "File did not get purged") end + + # Testing #274. Make sure target can be used without 'ensure'. + def test_target_without_ensure + source = tempfile() + dest = tempfile() + File.open(source, "w") { |f| f.puts "funtest" } + + obj = nil + assert_nothing_raised { + obj = Puppet::Type.newfile(:path => dest, :target => source) + } + + assert_apply(obj) + end end # $Id$ |