diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-02-28 07:20:25 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-02-28 07:20:25 +0000 |
commit | ebc4dd231e4970e9d3ccbbe57d0df9f38cf4c1aa (patch) | |
tree | 28e6e9e36228f391b7391f33142d4eebe64967f6 | |
parent | ff9ec47e4b9b13c043c41e5b74a0b0fb82ba8ba5 (diff) | |
download | puppet-ebc4dd231e4970e9d3ccbbe57d0df9f38cf4c1aa.tar.gz puppet-ebc4dd231e4970e9d3ccbbe57d0df9f38cf4c1aa.tar.xz puppet-ebc4dd231e4970e9d3ccbbe57d0df9f38cf4c1aa.zip |
Fixing #464 and #515.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2244 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r-- | lib/puppet/type/pfile.rb | 10 | ||||
-rw-r--r-- | lib/puppet/type/pfile/target.rb | 2 | ||||
-rwxr-xr-x | test/ral/types/file.rb | 28 |
3 files changed, 34 insertions, 6 deletions
diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb index d92a1e03d..22e7073c8 100644 --- a/lib/puppet/type/pfile.rb +++ b/lib/puppet/type/pfile.rb @@ -8,6 +8,7 @@ require 'puppet/network/server/fileserver' module Puppet newtype(:file) do + include Puppet::Util::MethodHelper @doc = "Manages local files, including setting ownership and permissions, creation of both files and directories, and retrieving entire files from remote servers. As Puppet matures, it @@ -564,7 +565,14 @@ module Puppet # object. def newchild(path, local, hash = {}) # make local copy of arguments - args = @arghash.dup + args = symbolize_options(@arghash) + + # There's probably a better way to do this, but we don't want + # to pass this info on. + if v = args[:ensure] + v = symbolize(v) + args.delete(:ensure) + end if path =~ %r{^#{File::SEPARATOR}} self.devfail( diff --git a/lib/puppet/type/pfile/target.rb b/lib/puppet/type/pfile/target.rb index 3de74bb74..12e8ea732 100644 --- a/lib/puppet/type/pfile/target.rb +++ b/lib/puppet/type/pfile/target.rb @@ -44,7 +44,7 @@ module Puppet end def insync? - if [:nochange, :notlink].include?(self.should) or @parent.should(:ensure) != :link + if [:nochange, :notlink].include?(self.should) return true else return super diff --git a/test/ral/types/file.rb b/test/ral/types/file.rb index 5b5f19299..57419164b 100755 --- a/test/ral/types/file.rb +++ b/test/ral/types/file.rb @@ -1452,7 +1452,7 @@ class TestFile < Test::Unit::TestCase file = File.join(dirs["other"], "file") sourcefile = File.join(dirs["source"], "sourcefile") - link = File.join(dirs["target"], "link") + link = File.join(dirs["target"], "sourcefile") File.open(file, "w") { |f| f.puts "other" } File.open(sourcefile, "w") { |f| f.puts "source" } @@ -1460,17 +1460,18 @@ class TestFile < Test::Unit::TestCase obj = Puppet::Type.type(:file).create( :path => dirs["target"], - :ensure => "file", + :ensure => :file, :source => dirs["source"], :recurse => true ) - trans = assert_events([:file_created, :file_created], obj) + trans = assert_apply(obj) newfile = File.join(dirs["target"], "sourcefile") - assert(File.exists?(newfile), "File did not get copied") + assert(File.directory?(dirs["target"]), "Dir did not get created") + assert(File.file?(newfile), "File did not get copied") assert_equal(File.read(sourcefile), File.read(newfile), "File did not get copied correctly.") @@ -2072,6 +2073,25 @@ class TestFile < Test::Unit::TestCase assert_equal(Puppet::Type.type(:filebucket)["puppet"].bucket, file.bucket, "did not default to the 'puppet' filebucket") end + + # #515 - make sure 'ensure' other than "link" is deleted during recursion + def test_ensure_deleted_during_recursion + dir = tempfile() + Dir.mkdir(dir) + file = File.join(dir, "file") + File.open(file, "w") { |f| f.puts "asdfasdf" } + + obj = Puppet::Type.newfile(:path => dir, :ensure => :directory, + :recurse => true) + + children = nil + assert_nothing_raised do + children = obj.eval_generate + end + fobj = obj.class[file] + assert(fobj, "did not create file object") + assert(fobj.should(:ensure) != :directory, "ensure was passed to child") + end end # $Id$ |