Skip to content

Commit

Permalink
filterx: list range check e2e tests
Browse files Browse the repository at this point in the history
Signed-off-by: shifter <shifter@axoflow.com>
  • Loading branch information
bshifter committed Sep 4, 2024
1 parent 0789d5a commit 8881661
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/light/functional_tests/filterx/test_filterx.py
Original file line number Diff line number Diff line change
Expand Up @@ -2008,3 +2008,34 @@ def test_get_sdata(config, syslog_ng):
},
},
}


def test_list_range_check_with_nulls(config, syslog_ng):
(file_true, file_false) = create_config(
config, r"""
$MSG = json();
js1 = json_array([null]);
js2 = json_array([null, "bar"]);
$MSG.caseA = js1[0];
$MSG.caseB = js2[0];
$MSG.caseC = js2[1];
""",
)
syslog_ng.start(config)

assert file_true.get_stats()["processed"] == 1
assert "processed" not in file_false.get_stats()
assert file_true.read_log() == '{"caseA":null,"caseB":null,"caseC":"bar"}\n'


def test_list_range_check_out_of_range(config, syslog_ng):
(file_true, file_false) = create_config(
config, r"""
$MSG = json();
js1 = json_array([null, "bar"]);
$MSG.caseA = js1[2];
""",
)
syslog_ng.start(config)
assert file_false.get_stats()["processed"] == 1
assert file_false.read_log() == "foobar\n"

0 comments on commit 8881661

Please sign in to comment.