This repository has been archived by the owner on Jun 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ryan Frantz
committed
Jun 8, 2014
1 parent
43f53c4
commit c4aff77
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |