fluentd-ui/spec/models/fluentd/setting/in_forward_spec.rb
Kenji Okimoto 66f5d8424f
Update specs to follow changes related to validation
Signed-off-by: Kenji Okimoto <okimoto@clear-code.com>
2018-06-21 11:20:13 +09:00

73 lines
1.5 KiB
Ruby

require 'spec_helper'
describe Fluentd::Setting::InForward do
let(:klass) { described_class }
let(:instance) { klass.new(valid_attributes) }
let(:valid_attributes) {
{}
}
describe "#valid?" do
it "should be valid" do
params = valid_attributes.dup
klass.new(params).should be_valid
end
end
describe "#plugin_name" do
subject { instance.plugin_name }
it { should == "forward" }
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 forward") }
end
describe "with security section" do
let(:valid_attributes) {
{
security: {
"0" => {
self_hostname: "test.fluentd",
shared_key: "secretsharedkey",
}
}
}
}
let(:expected) {
<<-CONFIG
<source>
@type forward
<security>
self_hostname test.fluentd
shared_key secretsharedkey
</security>
</source>
CONFIG
}
subject { instance.to_config.to_s }
it { should == expected }
end
describe "with invalid security section" do
it do
params = {
security: {
"0" => {
self_hostname: "test.fluentd",
}
}
}
object = klass.new(params)
object.validate
object.errors.full_messages.should == ["'shared_key' parameter is required, in section security"]
end
end
end