From 55c3c134c5c19103ed52fbd615d5af351fa9bb34 Mon Sep 17 00:00:00 2001 From: scott Chacon Date: Tue, 20 Nov 2007 12:08:11 -0800 Subject: [PATCH] added a test for the logger --- tests/units/test_logger.rb | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 tests/units/test_logger.rb 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 -- 2.11.4.GIT