aboutsummaryrefslogtreecommitdiffstats
path: root/test/functional/lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2024-08-01 12:58:13 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2024-08-01 12:58:13 +0100
commit066aa70abf2801d39ea7b9d433ec111f682616d2 (patch)
treeb6db09036f35bc1f24fe15afe171668d2b63aa40 /test/functional/lua
parent645f327b7702aca39017dc0ab92c8641b40d4416 (diff)
downloadrspamd-066aa70abf2801d39ea7b9d433ec111f682616d2.tar.gz
rspamd-066aa70abf2801d39ea7b9d433ec111f682616d2.zip
[Test] Add tests for group score limits
Diffstat (limited to 'test/functional/lua')
-rw-r--r--test/functional/lua/deps.lua2
-rw-r--r--test/functional/lua/limits.lua22
2 files changed, 23 insertions, 1 deletions
diff --git a/test/functional/lua/deps.lua b/test/functional/lua/deps.lua
index 6171db699..b78d3abb7 100644
--- a/test/functional/lua/deps.lua
+++ b/test/functional/lua/deps.lua
@@ -24,7 +24,7 @@ rspamd_config:register_virtual_symbol('TOP', 1.0, id)
rspamd_config:register_symbol('DEP1', 1.0, cb_dep1)
rspamd_config:register_dependency('DEP1', 'TOP')
-for i = 2,10 do
+for i = 2, 10 do
rspamd_config:register_symbol('DEP' .. tostring(i), 1.0, cb_gen(i - 1))
rspamd_config:register_dependency('DEP' .. tostring(i), 'DEP' .. tostring(i - 1))
end
diff --git a/test/functional/lua/limits.lua b/test/functional/lua/limits.lua
new file mode 100644
index 000000000..52fb47fb9
--- /dev/null
+++ b/test/functional/lua/limits.lua
@@ -0,0 +1,22 @@
+local true_cb_gen = function()
+ return function()
+ return true
+ end
+end
+
+local test_weights = { 1, 2, 4, 8, 16 }
+for _, i in ipairs(test_weights) do
+ rspamd_config:register_symbol('GR_POSITIVE' .. tostring(i), 1.0, true_cb_gen())
+
+ if i > 1 then
+ rspamd_config:register_dependency('GR_POSITIVE' .. tostring(i), 'GR_POSITIVE' .. tostring(i / 2))
+ end
+
+ rspamd_config:register_symbol('GR_NEGATIVE' .. tostring(i), 1.0, true_cb_gen())
+
+ if i > 1 then
+ rspamd_config:register_dependency('GR_NEGATIVE' .. tostring(i), 'GR_NEGATIVE' .. tostring(i / 2))
+ end
+end
+
+rspamd_config:register_dependency('GR_NEGATIVE1', 'GR_POSITIVE16') \ No newline at end of file