mirror of
https://github.com/fluent/fluentd-ui.git
synced 2025-08-14 10:17:06 +02:00
We must use `type` instead of `@type` to initialize model. Because we cannot define `@type` expected. Signed-off-by: Kenji Okimoto <okimoto@clear-code.com>
99 lines
1.8 KiB
Ruby
99 lines
1.8 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe Fluentd::Setting::InSyslog do
|
|
let(:klass) { described_class }
|
|
let(:instance) { klass.new(valid_attributes) }
|
|
let(:valid_attributes) {
|
|
{
|
|
tag: "foo.bar",
|
|
}
|
|
}
|
|
|
|
describe "#valid?" do
|
|
it "should be invalid if tag parameter lacked" do
|
|
params = valid_attributes.dup
|
|
params.delete(:tag)
|
|
klass.new(params).should_not be_valid
|
|
end
|
|
end
|
|
|
|
describe "#plugin_name" do
|
|
subject { instance.plugin_name }
|
|
it { should == "syslog" }
|
|
end
|
|
|
|
describe "#plugin_type" do
|
|
subject { instance.plugin_type }
|
|
it { should == "input" }
|
|
end
|
|
|
|
describe "#to_config" do
|
|
subject { instance.to_config.to_s }
|
|
it { should include("@type syslog") }
|
|
end
|
|
|
|
describe "with parse section" do
|
|
let(:valid_attributes) {
|
|
{
|
|
tag: "test",
|
|
parse_type: "syslog",
|
|
parse: {
|
|
"0" => {
|
|
"type" => "syslog",
|
|
"message_format" => "rfc5424"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let(:expected) {
|
|
<<-CONFIG
|
|
<source>
|
|
@type syslog
|
|
tag test
|
|
<parse>
|
|
@type syslog
|
|
message_format rfc5424
|
|
</parse>
|
|
</source>
|
|
CONFIG
|
|
}
|
|
it do
|
|
object = klass.new(valid_attributes)
|
|
puts object.to_config.to_s
|
|
object.to_config.to_s.should == expected
|
|
end
|
|
end
|
|
|
|
describe "with @log_level" do
|
|
let(:valid_attributes) {
|
|
{
|
|
tag: "test",
|
|
log_level: "debug",
|
|
parse: {
|
|
"0" => {
|
|
"type" => "syslog",
|
|
"message_format" => "rfc5424"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let(:expected) {
|
|
<<-CONFIG
|
|
<source>
|
|
@type syslog
|
|
tag test
|
|
@log_level debug
|
|
<parse>
|
|
@type syslog
|
|
message_format rfc5424
|
|
</parse>
|
|
</source>
|
|
CONFIG
|
|
}
|
|
it do
|
|
object = klass.new(valid_attributes)
|
|
object.to_config.to_s.should == expected
|
|
end
|
|
end
|
|
end
|