commit 225c8d9: [Test] task:remove_symbol() on grouped virtual symbol

Andrew Lewis nerf at judo.za.org
Tue Feb 1 20:49:04 UTC 2022


Author: Andrew Lewis
Date: 2022-02-01 13:09:19 +0200
URL: https://github.com/rspamd/rspamd/commit/225c8d92b64b76bc122d462966dc35109a399da2 (refs/pull/4055/head)

[Test] task:remove_symbol() on grouped virtual symbol

---
 test/functional/cases/001_merged/101_lua.robot |  5 +++++
 test/functional/configs/merged.conf            |  1 +
 test/functional/lua/remove_result.lua          | 26 ++++++++++++++++++++++++++
 3 files changed, 32 insertions(+)

diff --git a/test/functional/cases/001_merged/101_lua.robot b/test/functional/cases/001_merged/101_lua.robot
index 23637396a..ac4f8677a 100644
--- a/test/functional/cases/001_merged/101_lua.robot
+++ b/test/functional/cases/001_merged/101_lua.robot
@@ -34,6 +34,11 @@ Option Order
   Expect Symbol With Exact Options  OPTION_ORDER  one  two  three  4  5  a
   Expect Symbol With Exact Options  TBL_OPTION_ORDER  one  two  three  4  5  a
 
+Remove Result
+  Scan File  ${MESSAGE}  Settings={symbols_enabled = [REMOVE_RESULT_EXPECTED, REMOVE_RESULT_UNEXPECTED]}
+  Expect Symbol  REMOVE_RESULT_EXPECTED
+  Do Not Expect Symbol  REMOVE_RESULT_UNEXPECTED
+
 Rule conditions
   Scan File  ${MESSAGE}  Settings={symbols_enabled = [ANY_A]}
   Expect Symbol With Option  ANY_A  hello3
diff --git a/test/functional/configs/merged.conf b/test/functional/configs/merged.conf
index bda7044e1..60930f657 100644
--- a/test/functional/configs/merged.conf
+++ b/test/functional/configs/merged.conf
@@ -8,6 +8,7 @@ lua = "{= env.TESTDIR =}/lua/hashes.lua"
 lua = "{= env.TESTDIR =}/lua/maps_kv.lua"
 lua = "{= env.TESTDIR =}/lua/option_order.lua"
 lua = "{= env.TESTDIR =}/lua/recipients.lua"
+lua = "{= env.TESTDIR =}/lua/remove_result.lua"
 lua = "{= env.TESTDIR =}/lua/tlds.lua"
 
 # 104_get_from
diff --git a/test/functional/lua/remove_result.lua b/test/functional/lua/remove_result.lua
new file mode 100644
index 000000000..106d7f4cc
--- /dev/null
+++ b/test/functional/lua/remove_result.lua
@@ -0,0 +1,26 @@
+local id = rspamd_config:register_symbol({
+  name = 'REMOVE_RESULT_CB',
+  callback = function(task)
+    task:insert_result('REMOVE_RESULT_UNEXPECTED', 1.0, 'ohno')
+  end,
+  type = 'callback',
+})
+
+rspamd_config:register_symbol({
+  name = 'REMOVE_RESULT_UNEXPECTED',
+  type = 'virtual',
+  score = 0.1,
+  group = 'remove_result_test',
+  parent = id,
+})
+
+rspamd_config:register_symbol({
+  name = 'REMOVE_RESULT_EXPECTED',
+  callback = function(task)
+    return task:remove_result('REMOVE_RESULT_UNEXPECTED') and true or false
+  end,
+  type = 'normal',
+  score = 0.1,
+})
+
+rspamd_config:register_dependency('REMOVE_RESULT_EXPECTED', 'REMOVE_RESULT_UNEXPECTED')


More information about the Commits mailing list