summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xlib/puppet/type/pfile/ensure.rb5
-rwxr-xr-xtest/types/file.rb10
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/puppet/type/pfile/ensure.rb b/lib/puppet/type/pfile/ensure.rb
index 6f7b15d49..9e1eec86d 100755
--- a/lib/puppet/type/pfile/ensure.rb
+++ b/lib/puppet/type/pfile/ensure.rb
@@ -154,8 +154,9 @@ module Puppet
end
def sync
- unless self.should == :absent
- @parent.remove_existing(self.should)
+ @parent.remove_existing(self.should)
+ if self.should == :absent
+ return :file_removed
end
event = super
diff --git a/test/types/file.rb b/test/types/file.rb
index 80e2563d8..61ee14694 100755
--- a/test/types/file.rb
+++ b/test/types/file.rb
@@ -1913,6 +1913,16 @@ class TestFile < Test::Unit::TestCase
assert(fileobj, "did not generate file object")
assert_equal("/%s" % fileobj.ref, fileobj.path, "did not generate correct subfile path")
end
+
+ # Testing #403
+ def test_removal_with_content_set
+ path = tempfile()
+ File.open(path, "w") { |f| f.puts "yay" }
+ file = Puppet::Type.newfile(:name => path, :ensure => :absent, :content => "foo")
+
+ assert_apply(file)
+ assert(! FileTest.exists?(path), "File was not removed")
+ end
end
# $Id$