test/plugin/test_out_select.rb in fluent-plugin-select-0.0.2 vs test/plugin/test_out_select.rb in fluent-plugin-select-0.0.3

- old
+ new

@@ -64,12 +64,12 @@ d1 = create_driver(CONFIG, tag) d1.run do d1.emit(record, time) end - emits = d1.emits - assert_equal 0, emits.length + es = d1.emits + assert_equal 0, es.length end def test_syntax_error tag = "tag" time = Time.local(2012, 10, 10, 10, 10, 0) @@ -83,7 +83,52 @@ d1 = create_driver(syntax_error_config, tag) es = Fluent::OneEventStream.new(time.to_i, record) chain = Fluent::Test::TestOutputChain.new e = d1.instance.emit(tag, es, chain) assert e.kind_of?(SyntaxError) + end + + def test_match_tag_using_tag_param + tag = 'tag' #match + time = Time.local(2012, 10, 10, 10, 10, 10) #not match + record = {'code' => '300'} #not match + + d1 = create_driver %[ + select tag == "tag" or record["code"] == "200" or Time.at(time).sec == 0 + tag prefix.tag + ], tag + d1.run do + d1.emit(record, time) + end + emits = d1.emits + assert_equal 1, emits.length + assert_equal ["prefix.#{tag}", time.to_i, record], emits[0] + end + + def test_config_error + tag = 'tag' #match + time = Time.local(2012, 10, 10, 10, 10, 10) #not match + record = {'code' => '300'} #not match + + assert_raise(Fluent::ConfigError){ + create_driver %[ + select tag == "tag" or record["code"] == "200" or Time.at(time).sec == 0 + ], tag + } + end + + def test_timeout + tag = 'tag' #match + time = Time.local(2012, 10, 10, 10, 10, 10) #not match + record = {'code' => '300'} #not match + + d1 = create_driver %[ + select sleep 10 + add_prefix prefix + ], tag + d1.run do + d1.emit(record, time) + end + emits = d1.emits + assert_equal 0, emits.length end end