summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/units/test_logger.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/units/test_logger.rb b/tests/units/test_logger.rb
new file mode 100644
index 0000000..d88f09f
--- /dev/null
+++ b/tests/units/test_logger.rb
@@ -0,0 +1,38 @@
+#!/usr/bin/env ruby
+require 'logger'
+require File.dirname(__FILE__) + '/../test_helper'
+
+class TestLogger < Test::Unit::TestCase
+
+ def setup
+ set_file_paths
+ end
+
+ def test_logger
+ log = Tempfile.new('logfile')
+ log.close
+
+ logger = Logger.new(log.path)
+ logger.level = Logger::DEBUG
+
+ @git = Git.open(@wdir, :log => logger)
+ @git.branches.size
+
+ logc = File.read(log.path)
+ assert(/INFO -- : git branch -a/.match(logc))
+ assert(/DEBUG -- : \* git_grep/.match(logc))
+
+ log = Tempfile.new('logfile')
+ log.close
+ logger = Logger.new(log.path)
+ logger.level = Logger::INFO
+
+ @git = Git.open(@wdir, :log => logger)
+ @git.branches.size
+
+ logc = File.read(log.path)
+ assert(/INFO -- : git branch -a/.match(logc))
+ assert(!/DEBUG -- : \* git_grep/.match(logc))
+ end
+
+end