aboutsummaryrefslogtreecommitdiff
path: root/test/tc_mauve_configuration_builders_logger.rb
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2011-07-22 16:55:01 +0100
committerPatrick J Cherry <patrick@bytemark.co.uk>2011-07-22 16:55:01 +0100
commitfd23821950f0562a8995735105cd31fdc6d55933 (patch)
tree967df2f5647803a6c46f4d52003b2231c1de72cb /test/tc_mauve_configuration_builders_logger.rb
parentd3a3cfef9650b08f62db62bd7e86b673f9d77d0b (diff)
* Rejigged configuration
* Added --test and --verbose flags for the server config * Started proper test suite * Config parsing now gives more sensible errors + backtrace * Rejigged people and source lists
Diffstat (limited to 'test/tc_mauve_configuration_builders_logger.rb')
-rw-r--r--test/tc_mauve_configuration_builders_logger.rb59
1 files changed, 59 insertions, 0 deletions
diff --git a/test/tc_mauve_configuration_builders_logger.rb b/test/tc_mauve_configuration_builders_logger.rb
new file mode 100644
index 0000000..8a4bc4e
--- /dev/null
+++ b/test/tc_mauve_configuration_builders_logger.rb
@@ -0,0 +1,59 @@
+$:.unshift "../lib/"
+
+require 'test/unit'
+require 'pp'
+require 'mauve/configuration_builders/logger'
+
+class TcMauveConfigurationBuildersLogger < Test::Unit::TestCase
+
+ def test_load
+
+ config=<<EOF
+logger {
+ default_format "%d [ %l ] [ %12.12c ] %m"
+ default_level WARN
+
+ outputter "stdout"
+
+ outputter ("file") {
+ trunc false
+ filename "test.conf"
+ level DEBUG
+ }
+
+}
+EOF
+
+ assert_nothing_raised { Mauve::ConfigurationBuilder.parse(config) }
+
+ #
+ # Check that we've got the correct things set
+ #
+ logger = nil
+ assert_nothing_raised { logger = Log4r::Logger.get("Mauve") }
+ assert_equal(2, logger.outputters.length)
+
+ outputter = logger.outputters[0]
+
+ assert_kind_of(Log4r::StdoutOutputter, outputter)
+ assert_equal("%d [ %l ] [ %12.12c ] %m", outputter.formatter.pattern )
+ assert_equal(Log4r::WARN, outputter.level )
+
+ outputter = logger.outputters[1]
+ assert_kind_of(Log4r::FileOutputter, outputter)
+ assert_equal("%d [ %l ] [ %12.12c ] %m", outputter.formatter.pattern )
+ assert_equal(Log4r::DEBUG, outputter.level )
+ assert_equal(false, outputter.trunc )
+ assert_equal("test.conf", outputter.filename )
+ end
+
+ def test_levels
+ #
+ # Make sure our levels match those of log4r.
+ #
+ %w(DEBUG WARN FATAL ERROR INFO).each do |l|
+ assert_equal(Log4r.const_get(l), Mauve::LoggerConstants.const_get(l))
+ end
+ end
+
+end