added a test for the logger
authorscott Chacon <schacon@agadorsparticus.corp.reactrix.com>
Tue, 20 Nov 2007 20:08:11 +0000 (20 12:08 -0800)
committerscott Chacon <schacon@agadorsparticus.corp.reactrix.com>
Tue, 20 Nov 2007 20:08:11 +0000 (20 12:08 -0800)
tests/units/test_logger.rb [new file with mode: 0644]

diff --git a/tests/units/test_logger.rb b/tests/units/test_logger.rb
new file mode 100644 (file)
index 0000000..d88f09f
--- /dev/null
@@ -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