2016-12-06 15:44:04 +01:00
|
|
|
require_relative '../helper'
|
|
|
|
|
|
|
|
class MemLogger
|
|
|
|
def self.stream
|
|
|
|
@stream
|
|
|
|
end
|
|
|
|
def self.log_stream
|
|
|
|
@stream = StringIO.new
|
|
|
|
end
|
2018-05-20 13:45:48 +02:00
|
|
|
include Util::Logging
|
2016-12-06 15:44:04 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
class LoggerTest < MiniTest::Test
|
|
|
|
|
|
|
|
def setup
|
|
|
|
@logger = MemLogger.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_debug
|
|
|
|
assert @logger.log.debug "Debug"
|
|
|
|
end
|
|
|
|
def test_info
|
|
|
|
assert @logger.log.info "Info"
|
|
|
|
assert MemLogger.stream.string.include? "Info"
|
|
|
|
end
|
|
|
|
def test_warn
|
|
|
|
assert @logger.log.warn "Warn"
|
|
|
|
assert MemLogger.stream.string.include? "Warn"
|
|
|
|
end
|
|
|
|
def test_error
|
|
|
|
assert @logger.log.error "Error"
|
|
|
|
assert MemLogger.stream.string.include? "Error"
|
|
|
|
end
|
2016-12-15 21:14:24 +01:00
|
|
|
def test_set_level
|
|
|
|
[:unknown, :fatal, :error , :warn, :info].each do |level|
|
2016-12-15 21:28:42 +01:00
|
|
|
assert MemLogger.log_level( level)
|
2016-12-15 21:14:24 +01:00
|
|
|
end
|
|
|
|
end
|
2016-12-06 15:44:04 +01:00
|
|
|
end
|