Skip to content

Commit

Permalink
filterx: add E2E test for unset_empties()
Browse files Browse the repository at this point in the history
Signed-off-by: Attila Szakacs <[email protected]>
  • Loading branch information
alltilla committed Jun 7, 2024
1 parent 26e8f77 commit b37733f
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/light/functional_tests/filterx/test_filterx.py
Original file line number Diff line number Diff line change
Expand Up @@ -1509,3 +1509,28 @@ def test_vars(config, syslog_ng):
assert file_true.get_stats()["processed"] == 1
assert "processed" not in file_false.get_stats()
assert file_true.read_log() == '{"logmsg_variable":"foo","pipeline_level_variable":"baz","log":{"body":"foobar","attributes":{"attribute":42}},"js_array":[1,2,3,[4,5,6]]}\n'


def test_unset_empties(config, syslog_ng):
(file_true, file_false) = create_config(
config, r"""
dict = json({"foo": "", "almafa": null, "kortefa": {"a":{"s":{"d":{}}}}, "szilvafa": [[[]]]});
defaults_dict = dict;
explicit_dict = dict;
unset_empties(defaults_dict);
unset_empties(explicit_dict, recursive=true, string=true, number=true, null=true, dict=true, list=true);
list = json_array(["", null, {"a":{"s":{"d":{}}}}, [[[]]]]);
defaults_list = list;
explicit_list = list;
unset_empties(defaults_list);
unset_empties(explicit_list, recursive=true, string=true, number=true, null=true, dict=true, list=true);
$MSG = json_array([defaults_dict, explicit_dict, defaults_list, explicit_list]);
""",
)
syslog_ng.start(config)

assert file_true.get_stats()["processed"] == 1
assert "processed" not in file_false.get_stats()
assert file_true.read_log() == "[{},{},[],[]]\n"

0 comments on commit b37733f

Please sign in to comment.