mirror of
https://github.com/fluent/fluentd-ui.git
synced 2025-08-14 10:17:06 +02:00
63 lines
1.4 KiB
Ruby
63 lines
1.4 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe Fluentd::Setting::OutMongo do
|
|
let(:klass) { described_class }
|
|
let(:instance) { klass.new(valid_attributes) }
|
|
let(:valid_attributes) {
|
|
{
|
|
pattern: "mongo.*.*",
|
|
host: "example.com",
|
|
port: 12345,
|
|
database: "mongodb",
|
|
tag_mapped: "true",
|
|
}
|
|
}
|
|
|
|
describe "#valid?" do
|
|
it "should be invalid if database parameter is missing" do
|
|
params = valid_attributes.dup
|
|
params.delete(:database)
|
|
instance = klass.new(params)
|
|
instance.should_not be_valid
|
|
instance.errors.full_messages.should == ["connection_string or database parameter is required"]
|
|
end
|
|
|
|
it "should be invalid if collection is missing" do
|
|
params = {
|
|
pattern: "mongo.*.*",
|
|
host: "example.com",
|
|
port: 12345,
|
|
database: "mongodb",
|
|
}
|
|
instance = klass.new(params)
|
|
instance.should_not be_valid
|
|
instance.errors.full_messages.should == ["normal mode requires collection parameter"]
|
|
end
|
|
end
|
|
|
|
describe "#plugin_name" do
|
|
subject { instance.plugin_name }
|
|
it { should == "mongo" }
|
|
end
|
|
|
|
describe "#plugin_type" do
|
|
it { instance.plugin_type.should == "output" }
|
|
end
|
|
|
|
describe "#to_config" do
|
|
subject { instance.to_config.to_s }
|
|
let(:expected) {
|
|
<<-CONFIG
|
|
<match mongo.*.*>
|
|
@type mongo
|
|
database mongodb
|
|
host example.com
|
|
port 12345
|
|
tag_mapped true
|
|
</match>
|
|
CONFIG
|
|
}
|
|
it { should == expected}
|
|
end
|
|
end
|