Skip to content

Commit

Permalink
Added UTs
Browse files Browse the repository at this point in the history
Signed-off-by: Athish Pranav D <athishanna@gmail.com>
  • Loading branch information
Athishpranav2003 committed Sep 12, 2024
1 parent ab9130d commit cfb9f1d
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion test/plugin/test_filter_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,23 @@ def test_filter

end

def test_filter_with_multiple_records
d1 = create_driver(%[
key_name data
<parse>
@type json
</parse>
])
time = Fluent::EventTime.from_time(@default_time)
d1.run(default_tag: @tag) do
d1.feed(time, {'data' => '[{"xxx_1":"first","yyy":"second"}, {"xxx_2":"first", "yyy_2":"second"}]'})
end
filtered = d1.filtered
assert_equal 2, filtered.length
assert_equal ({"xxx_1"=>"first", "yyy"=>"second"}), filtered[0][1]
assert_equal ({"xxx_2"=>"first", "yyy_2"=>"second"}), filtered[1][1]
end

data(:keep_key_name => false,
:remove_key_name => true)
def test_filter_with_reserved_data(remove_key_name)
Expand Down Expand Up @@ -633,7 +650,7 @@ def test_filter_invalid_byte
def test_filter_key_not_exist
d = create_driver(CONFIG_NOT_IGNORE)
flexmock(d.instance.router).should_receive(:emit_error_event).
with(String, Integer, Hash, ArgumentError.new("data does not exist")).once
with(String, Integer, Hash, ArgumentError).once
assert_nothing_raised {
d.run do
d.feed(@tag, Fluent::EventTime.now.to_i, {'foo' => 'bar'})
Expand Down

0 comments on commit cfb9f1d

Please sign in to comment.