Skip to content

Commit

Permalink
ci: filter_parser: add unassumed error tests
Browse files Browse the repository at this point in the history
Signed-off-by: Daijiro Fukuda <[email protected]>
  • Loading branch information
daipom committed Nov 26, 2024
1 parent 08c98dc commit 788417d
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/plugin/test_filter_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -786,5 +786,39 @@ def test_invalid_byte(data)
expected_errors: [ArgumentError.new(error_msg)]
)
end

data(
"with default" => {
records: [{'data' => '{"foo":"bar"}'}],
additional_config: "",
expected_records: [],
expected_error_records: [{'data' => '{"foo":"bar"}'}],
expected_errors: [Fluent::Plugin::Parser::ParserError.new("parse failed This is a dummy unassumed error")],
},
"with disabled emit_invalid_record_to_error" => {
records: [{'data' => '{"foo":"bar"}'}],
additional_config: "emit_invalid_record_to_error false",
expected_records: [],
expected_error_records: [],
expected_errors: [],
},
)
def test_unassumed_error(data)
any_instance_of(Fluent::Plugin::JSONParser) do |klass|
stub(klass).parse do
raise RuntimeError, "This is a dummy unassumed error"
end
end

driver = create_driver(<<~EOC)
key_name data
#{data[:additional_config]}
<parse>
@type json
</parse>
EOC

run_and_assert(driver, **data.except(:additional_config))
end
end
end

0 comments on commit 788417d

Please sign in to comment.