summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-10-28 18:09:55 -0500
committerLuke Kanies <luke@madstop.com>2008-11-04 16:20:45 -0600
commit05e1325891b2ab22088dcd34dd54e4afcbf59ddb (patch)
tree46f28ce17354bac900ba513402dc94e889ab7b4e /spec
parent6f7ccff8bb764dffd1d41d5391dd79f7bd4a387c (diff)
Moving a file purging test to rspec
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec')
-rwxr-xr-xspec/integration/type/file.rb49
1 files changed, 49 insertions, 0 deletions
diff --git a/spec/integration/type/file.rb b/spec/integration/type/file.rb
index 7f5e9cbac..c9e0d19c6 100755
--- a/spec/integration/type/file.rb
+++ b/spec/integration/type/file.rb
@@ -213,4 +213,53 @@ describe Puppet::Type.type(:file) do
File.should_not be_exist(dest)
end
+
+ describe "when purging files" do
+ before do
+ @sourcedir = tmpfile("purge_source")
+ @destdir = tmpfile("purge_dest")
+ Dir.mkdir(@sourcedir)
+ Dir.mkdir(@destdir)
+ @sourcefile = File.join(@sourcedir, "sourcefile")
+ @copiedfile = File.join(@destdir, "sourcefile")
+ @localfile = File.join(@destdir, "localfile")
+ @purgee = File.join(@destdir, "to_be_purged")
+ File.open(@localfile, "w") { |f| f.puts "rahtest" }
+ File.open(@sourcefile, "w") { |f| f.puts "funtest" }
+ # this file should get removed
+ File.open(@purgee, "w") { |f| f.puts "footest" }
+
+ @lfobj = Puppet::Type.newfile(
+ :title => "localfile",
+ :path => @localfile,
+ :content => "rahtest\n",
+ :ensure => :file,
+ :backup => false
+ )
+
+ @destobj = Puppet::Type.newfile(:title => "destdir", :path => @destdir,
+ :source => @sourcedir,
+ :backup => false,
+ :purge => true,
+ :recurse => true)
+
+ @catalog = Puppet::Node::Catalog.new
+ @catalog.add_resource @lfobj, @destobj
+ end
+
+ it "should still copy remote files" do
+ @catalog.apply
+ FileTest.should be_exist(@copiedfile)
+ end
+
+ it "should not purge managed, local files" do
+ @catalog.apply
+ FileTest.should be_exist(@localfile)
+ end
+
+ it "should purge files that are neither remote nor otherwise managed" do
+ @catalog.apply
+ FileTest.should_not be_exist(@purgee)
+ end
+ end
end