From 6ed21a91efac475d2d4c67839500098307762615 Mon Sep 17 00:00:00 2001 From: Balazs Scheidler Date: Sun, 16 Feb 2025 09:40:16 +0100 Subject: [PATCH] light: add coverage for the repr() function Signed-off-by: Balazs Scheidler --- .../filterx/test_filterx_funcs.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/light/functional_tests/filterx/test_filterx_funcs.py b/tests/light/functional_tests/filterx/test_filterx_funcs.py index 7574681fe..6c86afcb7 100644 --- a/tests/light/functional_tests/filterx/test_filterx_funcs.py +++ b/tests/light/functional_tests/filterx/test_filterx_funcs.py @@ -107,6 +107,21 @@ def test_lower(config, syslog_ng): assert file_final.read_log() == """{"literal":"abc","variable":"foobar","host":"hostname"}\n""" +def test_repr(config, syslog_ng): + (file_final,) = create_config( + config, r""" + dt=strptime("2000-01-01T00:00:00Z", "%Y-%m-%dT%H:%M:%S%z"); + $MSG = json(); + $MSG.repr = repr(dt); + $MSG.str = string(dt); + """, + ) + syslog_ng.start(config) + + assert file_final.get_stats()["processed"] == 1 + assert file_final.read_log() == """{"repr":"2000-01-01T00:00:00.000+00:00","str":"946684800.000000"}\n""" + + def test_startswith_with_various_arguments(config, syslog_ng): (file_final,) = create_config( config, r"""