From 01e9f375914e1156d7ba8750236556ce52f91996 Mon Sep 17 00:00:00 2001 From: wiibaa Date: Tue, 23 Sep 2014 07:21:05 +0200 Subject: [PATCH] test and fix for LOGSTASH-2288 --- lib/logstash/config/config_ast.rb | 5 +---- spec/conditionals/test.rb | 27 ++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/lib/logstash/config/config_ast.rb b/lib/logstash/config/config_ast.rb index a88bf5f5915..3a31c04a3fb 100644 --- a/lib/logstash/config/config_ast.rb +++ b/lib/logstash/config/config_ast.rb @@ -74,10 +74,7 @@ def compile # 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}" } diff --git a/spec/conditionals/test.rb b/spec/conditionals/test.rb index 7407ecd008c..95166e63be5 100644 --- a/spec/conditionals/test.rb +++ b/spec/conditionals/test.rb @@ -21,7 +21,32 @@ def conditional(expression, &block) 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