fluentd-ui/test/models/fluentd/setting/in_syslog_test.rb
Kenji Okimoto 5b882568f7
Add test/models/fluentd/setting/*_test.rb
Signed-off-by: Kenji Okimoto <okimoto@clear-code.com>
2018-08-02 14:10:46 +09:00

89 lines
1.8 KiB
Ruby

require "test_helper"
module Fluentd::Setting
class InSyslogTest < ActiveSupport::TestCase
setup do
@klass = Fluentd::Setting::InSyslog
@instance = @klass.new({ tag: "foo.bar" })
end
test "#valid?" do
assert do
@instance.valid?
end
end
test "invalid" do
assert do
!@klass.new({}).valid?
end
end
test "#plugin_name" do
assert_equal("syslog", @instance.plugin_name)
end
test "#plugin_type" do
assert_equal("input", @instance.plugin_type)
end
test "#to_config" do
assert do
@instance.to_config.to_s.include?("@type syslog")
end
end
test "with parse section" do
params = {
tag: "test",
parse_type: "syslog",
parse: {
"0" => {
"type" => "syslog",
"message_format" => "rfc5424"
}
}
}
@instance = @klass.new(params)
expected = <<-CONFIG.strip_heredoc
<source>
@type syslog
tag test
<parse>
@type syslog
message_format rfc5424
</parse>
</source>
CONFIG
assert_equal(expected, @instance.to_config.to_s)
end
test "with @log_level" do
params = {
tag: "test",
log_level: "debug",
parse_type: "syslog",
parse: {
"0" => {
"type" => "syslog",
"message_format" => "rfc5424"
}
}
}
@instance = @klass.new(params)
expected = <<-CONFIG.strip_heredoc
<source>
@type syslog
tag test
@log_level debug
<parse>
@type syslog
message_format rfc5424
</parse>
</source>
CONFIG
assert_equal(expected, @instance.to_config.to_s)
end
end
end