Navigation Menu

Skip to content

Commit

Permalink
[Test] task:remove_symbol() on grouped virtual symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
fatalbanana committed Feb 1, 2022
1 parent c9f2631 commit 225c8d9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/functional/cases/001_merged/101_lua.robot
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/functional/configs/merged.conf
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions 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')

0 comments on commit 225c8d9

Please sign in to comment.