]> source.dussan.org Git - rspamd.git/commitdiff
[Test] task:remove_symbol() on grouped virtual symbol 4055/head
authorAndrew Lewis <nerf@judo.za.org>
Tue, 1 Feb 2022 11:09:19 +0000 (13:09 +0200)
committerAndrew Lewis <nerf@judo.za.org>
Tue, 1 Feb 2022 11:09:19 +0000 (13:09 +0200)
test/functional/cases/001_merged/101_lua.robot
test/functional/configs/merged.conf
test/functional/lua/remove_result.lua [new file with mode: 0644]

index 23637396aa9078d55496636e0794896c01da6d82..ac4f8677a9ba2633e91e0c9877426a95a16cc412 100644 (file)
@@ -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
index bda7044e11c3949c4cc309ea0b2ae49218189a59..60930f657c6cb3fc2c67eea56236d6600560b62e 100644 (file)
@@ -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 (file)
index 0000000..106d7f4
--- /dev/null
@@ -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')