test and fix for LOGSTASH-2288

This commit is contained in:
wiibaa 2014-09-23 07:21:05 +02:00
parent 9c16d78a66
commit 01e9f37591
2 changed files with 27 additions and 5 deletions

View file

@ -74,10 +74,7 @@ module LogStash; module Config; module AST
# defines @filter_func and @output_func
definitions << "@#{type}_func = lambda do |event, &block|"
if type == "filter"
definitions << " events = [event]"
end
definitions << " events = [event]"
definitions << " @logger.debug? && @logger.debug(\"#{type} received\", :event => event.to_hash)"
sections.select { |s| s.plugin_type.text_value == type }.each do |s|
definitions << s.compile.split("\n", -1).map { |e| " #{e}" }

View file

@ -21,7 +21,32 @@ module ConditionalFanciness
end
end
describe "conditionals" do
describe "conditionals in output" do
extend LogStash::RSpec
extend ConditionalFanciness
describe "simple" do
config <<-CONFIG
input {
generator {
message => '{"foo":{"bar"},"baz": "quux"}'
count => 1
}
}
output {
if [foo] == "bar" {
stdout { }
}
}
CONFIG
agent do
#LOGSTASH-2288, should not fail raising an exception
end
end
end
describe "conditionals in filter" do
extend LogStash::RSpec
extend ConditionalFanciness