spec/outputs/sns_spec.rb in logstash-output-sns-4.0.7 vs spec/outputs/sns_spec.rb in logstash-output-sns-4.0.8
- old
+ new
@@ -82,9 +82,27 @@
it "should return the host if 'sns_subject' not set" do
event = LogStash::Event.new("host" => "foo")
expect(subject.send(:event_subject, event)).to eql("foo")
end
+ it "should return the host name (ECS compatibility) if 'sns_subject' not set" do
+ event = LogStash::Event.new
+ event.set('[host][hostname]', 'server1')
+ expect(subject.send(:event_subject, event)).to eql('server1')
+ end
+
+ it "should return the host IP (ECS compatibility) if 'sns_subject' not set" do
+ event = LogStash::Event.new
+ event.set('host.geo.name', 'Vychodne Pobrezie')
+ expect(subject.send(:event_subject, event)).to eql(LogStash::Outputs::Sns::NO_SUBJECT)
+ end
+
+ it "should return no subject when no info in host object (ECS compatibility) if 'sns_subject' not set" do
+ event = LogStash::Event.new
+ event.set('[host][ip]', '192.168.1.111')
+ expect(subject.send(:event_subject, event)).to eql('192.168.1.111')
+ end
+
it "should return 'NO SUBJECT' when subject cannot be determined" do
event = LogStash::Event.new("foo" => "bar")
expect(subject.send(:event_subject, event)).to eql(LogStash::Outputs::Sns::NO_SUBJECT)
end
end