Skip to content

Commit

Permalink
filterx: add E2E tests for flatten()
Browse files Browse the repository at this point in the history
Signed-off-by: Attila Szakacs <[email protected]>
  • Loading branch information
alltilla committed Jul 29, 2024
1 parent 0511ad0 commit f2f51b5
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/light/functional_tests/filterx/test_filterx.py
Original file line number Diff line number Diff line change
Expand Up @@ -1806,3 +1806,27 @@ def test_add_operator_for_base_types(config, syslog_ng):
r""""dict_dict":{"foo":"bar","baz":"other"}}""" + "\n"
)
assert file_true.read_log() == exp


def test_flatten(config, syslog_ng):
(file_true, file_false) = create_config(
config, r"""
dict = json({"top_level_field":42,"top_level_dict":{"inner_field":1337,"inner_dict":{"inner_inner_field":1}}});
default_separator = dict;
custom_separator = dict;
flatten(default_separator);
flatten(custom_separator, separator="->");
$MSG = json_array([default_separator, custom_separator]);
""",
)
syslog_ng.start(config)

assert file_true.get_stats()["processed"] == 1
assert "processed" not in file_false.get_stats()
assert file_true.read_log() == '[' \
'{"top_level_field":42,"top_level_dict.inner_dict.inner_inner_field":1,"top_level_dict.inner_field":1337},' \
'{"top_level_field":42,"top_level_dict->inner_dict->inner_inner_field":1,"top_level_dict->inner_field":1337}' \
']\n'

0 comments on commit f2f51b5

Please sign in to comment.