summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-09-03 02:37:56 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-09-03 02:37:56 +0000
commitff18e5592467c4b8fe2cedf48cd8f9332e0eff32 (patch)
treee82086f972e4e432a9b70cda723d85997e7ffc82 /test
parent18320ee5144c76de4d1d2c5c0fa27fd719882991 (diff)
downloadpuppet-ff18e5592467c4b8fe2cedf48cd8f9332e0eff32.tar.gz
puppet-ff18e5592467c4b8fe2cedf48cd8f9332e0eff32.tar.xz
puppet-ff18e5592467c4b8fe2cedf48cd8f9332e0eff32.zip
Adding support for file purging, as requested in #250. Any unmanaged files in a purge-enabled directory will be removed.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1539 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
-rw-r--r--test/types/file.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/types/file.rb b/test/types/file.rb
index 1d962ee30..3dc296cc0 100644
--- a/test/types/file.rb
+++ b/test/types/file.rb
@@ -1359,6 +1359,41 @@ class TestFile < Test::Unit::TestCase
assert_equal("yayness", File.read(path), "Content did not get set correctly")
end
+
+ # Make sure unmanaged files can be purged.
+ def test_purge
+ sourcedir = tempfile()
+ destdir = tempfile()
+ Dir.mkdir(sourcedir)
+ Dir.mkdir(destdir)
+ sourcefile = File.join(sourcedir, "sourcefile")
+ dsourcefile = File.join(destdir, "sourcefile")
+ localfile = File.join(destdir, "localfile")
+ randfile = File.join(destdir, "random")
+ File.open(sourcefile, "w") { |f| f.puts "funtest" }
+ # this file should get removed
+ File.open(randfile, "w") { |f| f.puts "footest" }
+
+ lfobj = Puppet::Type.newfile(:path => localfile, :content => "rahtest")
+
+ destobj = Puppet::Type.newfile(:path => destdir,
+ :source => sourcedir,
+ :recurse => true)
+
+
+ assert_apply(lfobj, destobj)
+
+ assert(FileTest.exists?(dsourcefile), "File did not get copied")
+ assert(FileTest.exists?(localfile), "File did not get created")
+ assert(FileTest.exists?(randfile), "File got prematurely purged")
+
+ assert_nothing_raised { destobj[:purge] = true }
+ assert_apply(lfobj, destobj)
+
+ assert(FileTest.exists?(dsourcefile), "File got purged")
+ assert(FileTest.exists?(localfile), "File got purged")
+ assert(! FileTest.exists?(randfile), "File did not get purged")
+ end
end
# $Id$