From 795a5a0551ba8c2fcf4dcbdb6a3e9ab3fb57bf86 Mon Sep 17 00:00:00 2001 From: luke Date: Tue, 6 Sep 2005 04:21:55 +0000 Subject: adding all of the work necessary for tidying git-svn-id: https://reductivelabs.com/svn/puppet/trunk@627 980ebf18-57e1-0310-9a29-db15c13687c0 --- test/server/tc_bucket.rb | 2 +- test/types/tc_tidy.rb | 60 +++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 58 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/server/tc_bucket.rb b/test/server/tc_bucket.rb index 79d8afcd0..0d81474a3 100644 --- a/test/server/tc_bucket.rb +++ b/test/server/tc_bucket.rb @@ -172,7 +172,7 @@ class TestBucket < Test::Unit::TestCase server = nil client = nil - port = Puppet::Server::FileBucket::DEFAULTPORT + port = Puppet[:masterport] serverthread = nil pid = fork { server = Puppet::Server.new( diff --git a/test/types/tc_tidy.rb b/test/types/tc_tidy.rb index 0e6bcd562..748763811 100755 --- a/test/types/tc_tidy.rb +++ b/test/types/tc_tidy.rb @@ -45,12 +45,66 @@ class TestTidy < TestPuppet f.puts rand(100) } - Puppet::Type::Tidy.new( - :name => file + tidy = Puppet::Type::Tidy.new( + :name => dir, + :size => "1b", + :recurse => true ) + + comp = newcomp("tidytesting", tidy) + + trans = nil + assert_nothing_raised { + trans = comp.evaluate + } + event = nil + assert_nothing_raised { + event = trans.evaluate.collect { |e| e.event } + } + + assert_equal(1, event.length, "Got no events on tidy") + assert_equal([:file_tidied], event, "Got incorrect event on tidy") + + assert(!FileTest.exists?(file), "Tidied file still exists") + end + + def test_tidydirs + dir = mktmpdir + file = File.join(dir, "tidytesting") + File.open(file, "w") { |f| + f.puts rand(100) + } + + tidy = Puppet::Type::Tidy.new( + :name => dir, + :size => "1b", + :age => "1s", + :rmdirs => true, + :recurse => true + ) + + comp = newcomp("tidytesting", tidy) + + sleep(2) + trans = nil + assert_nothing_raised { + trans = comp.evaluate + } + event = nil + assert_nothing_raised { + event = trans.evaluate.collect { |e| e.event } + } + + assert(!FileTest.exists?(file), "Tidied %s still exists" % file) + assert(!FileTest.exists?(dir), "Tidied %s still exists" % dir) + + assert_equal(2, event.length, "Got %s events instead of %s on tidy" % + [event.length, 2]) + assert_equal([:file_tidied, :file_tidied], event, + "Got incorrect events on tidy") end - def test_recursion + def disabled_test_recursion source = mktmpdir() FileUtils.cd(source) { mkranddirsandfiles() -- cgit