Skip to content
This repository has been archived by the owner on Jun 13, 2020. It is now read-only.

Commit

Permalink
Added logging test.
Browse files Browse the repository at this point in the history
- Related to #4 and #12.
  • Loading branch information
Ryan Frantz committed Jun 8, 2014
1 parent 43f53c4 commit c4aff77
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/unit/test_logging.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
require 'minitest/autorun'

# I assume cat'ing to the LOAD path goes away when we're a real gem.
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
require 'nagios-herald'
require 'nagios-herald/config'
require 'nagios-herald/logging'

# Test the Config module.
class TestLogging < MiniTest::Unit::TestCase
include NagiosHerald::Logging

# Initial setup before we execute tests
def setup
@options = {}
@options['config_file'] = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'etc', 'config.yml.example'))
@tmp_logfile = '/tmp/nagios-herald-logging.log'
# Specify a log file
@options['logfile'] = @tmp_logfile
# Load the config
NagiosHerald::Config.load(@options)
end

def test_info_message
#INFO -- test_logging.rb (TestLogging): Testing nagios-herald logging
logger.info "Testing nagios-herald logging"
@log_message = File.new(@tmp_logfile, 'r').read
assert_match /INFO.+Testing nagios-herald logging/, @log_message
end

def teardown
File.delete(@tmp_logfile)
end

end

0 comments on commit c4aff77

Please sign in to comment.