aboutsummaryrefslogtreecommitdiff
path: root/test/th_mauve.rb
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2011-08-17 11:08:07 +0100
committerPatrick J Cherry <patrick@bytemark.co.uk>2011-08-17 11:08:07 +0100
commit8c8e5ae926e0009743fe92dccb588783640a6022 (patch)
treee23eea583beac0caf5fb3e45a33b4d2ac7796abf /test/th_mauve.rb
parent79dcf16ec6d229d6c31e055ed8e6a98327526a3a (diff)
* Reminder notifications now take the same path to notify as initial alerts
* Threading tidied -- processor will not do anything unless the timer has frozen * Person#send_alert now tidied and merged with alert_changed * POP3 server only shows alerts relevant to the user * Server now defaults to using an in-memory SQLite database (good for testing) * Server initializes a blank mauve config. * Tests tidied up
Diffstat (limited to 'test/th_mauve.rb')
-rw-r--r--test/th_mauve.rb91
1 files changed, 91 insertions, 0 deletions
diff --git a/test/th_mauve.rb b/test/th_mauve.rb
new file mode 100644
index 0000000..a113ad0
--- /dev/null
+++ b/test/th_mauve.rb
@@ -0,0 +1,91 @@
+require 'test/unit'
+require 'mauve/datamapper'
+require 'timecop'
+require 'log4r'
+require 'pp'
+
+module Mauve
+ class TestOutputter < Log4r::Outputter
+ def initialize( _name, hash={})
+ @buffer = []
+ super
+ end
+
+ def pop ; @buffer.pop ; end
+ def shift ; @buffer.shift ; end
+
+ def write(data)
+ @buffer << data
+ end
+
+ def flush
+ print "\n" if @buffer.length > 0
+ while d = @buffer.shift
+ print d
+ end
+ end
+
+ end
+end
+
+
+module Mauve
+ class UnitTest < Test::Unit::TestCase
+
+ def setup
+ setup_logger
+ setup_time
+ end
+
+ def teardown
+ teardown_logger
+ teardown_time
+ end
+
+ def setup_logger
+ @logger = Log4r::Logger.new 'Mauve'
+ @outputter = Mauve::TestOutputter.new("test")
+ @outputter.formatter = Log4r::PatternFormatter.new( :pattern => "%d %l %m" )
+ @outputter.level = Log4r::DEBUG
+ @logger.outputters << @outputter
+ return @logger
+ end
+
+ def logger_pop
+ @outputter.pop
+ end
+
+ def teardown_logger
+ logger = Log4r::Logger['Mauve']
+ return if logger.nil?
+
+ o = logger.outputters.find{|o| o.name == "test"}
+ o.flush if o.respond_to?("flush")
+ # Delete the logger.
+ Log4r::Logger::Repository.instance.loggers.delete('Mauve')
+ end
+
+ def setup_database
+ DataMapper::Model.raise_on_save_failure = true
+ end
+
+ def teardown_database
+ DataObjects::Pooling.pools.each{|pool| pool.dispose}
+ end
+
+ def setup_time
+ Timecop.freeze(Time.local(2011,8,1,0,0,0,0))
+ end
+
+ def teardown_time
+ Timecop.return
+ end
+
+ def default_test
+ #
+ #
+ flunk("No tests specified") unless self.class == Mauve::UnitTest
+ end
+
+ end
+end