-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from dlackty/fix-up-tag-rewrite
Fix tag rewrite and switch to minitest
- Loading branch information
Showing
4 changed files
with
61 additions
and
35 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
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
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 |
---|---|---|
@@ -1,36 +1,62 @@ | ||
require "test_helper" | ||
require "fluent/plugin/out_remote_syslog" | ||
|
||
class RemoteSyslogOutputTest < Test::Unit::TestCase | ||
class RemoteSyslogOutputTest < MiniTest::Unit::TestCase | ||
def setup | ||
super | ||
Fluent::Test.setup | ||
end | ||
|
||
CONFIG = %[ | ||
type remote_syslog | ||
hostname foo.com | ||
host example.com | ||
port 5566 | ||
severity debug | ||
tag testunit | ||
] | ||
|
||
def create_driver(conf = CONFIG) | ||
Fluent::Test::OutputTestDriver.new(Fluent::RemoteSyslogOutput) {}.configure(conf) | ||
def create_driver(conf = CONFIG, tag = "test.remote_syslog") | ||
Fluent::Test::OutputTestDriver.new(Fluent::RemoteSyslogOutput, tag) {}.configure(conf) | ||
end | ||
|
||
def test_configure | ||
d = create_driver | ||
logger = d.instance.instance_variable_get(:@logger) | ||
d = create_driver %[ | ||
type remote_syslog | ||
hostname foo.com | ||
host example.com | ||
port 5566 | ||
severity debug | ||
tag minitest | ||
] | ||
|
||
d.run do | ||
d.emit(message: "foo") | ||
end | ||
|
||
loggers = d.instance.instance_variable_get(:@loggers) | ||
refute_empty loggers | ||
|
||
logger = loggers.values.first | ||
|
||
assert_not_nil logger | ||
assert_equal "example.com", logger.instance_variable_get(:@remote_hostname) | ||
assert_equal 5566, logger.instance_variable_get(:@remote_port) | ||
|
||
p = logger.instance_variable_get(:@packet) | ||
assert_equal "foo.com", p.hostname | ||
assert_equal 1, p.facility | ||
assert_equal "testunit", p.tag | ||
assert_equal "minitest", p.tag | ||
assert_equal 7, p.severity | ||
end | ||
|
||
def test_rewrite_tag | ||
d = create_driver %[ | ||
type remote_syslog | ||
hostname foo.com | ||
host example.com | ||
port 5566 | ||
severity debug | ||
tag rewrited.${tag_parts[1]} | ||
] | ||
|
||
d.run do | ||
d.emit(message: "foo") | ||
end | ||
|
||
loggers = d.instance.instance_variable_get(:@loggers) | ||
logger = loggers.values.first | ||
|
||
p = logger.instance_variable_get(:@packet) | ||
assert_equal "rewrited.remote_syslog", p.tag | ||
end | ||
end |
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) | ||
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib")) | ||
$LOAD_PATH.unshift(File.dirname(__FILE__)) | ||
|
||
require 'test/unit' | ||
require 'fluent/test' | ||
require "minitest/autorun" | ||
require "minitest/unit" | ||
require "minitest/pride" | ||
require "fluent/test" |