aboutsummaryrefslogtreecommitdiffstats
path: root/test/lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-11-20 16:33:34 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-11-20 16:33:34 +0000
commitc3896936f524bd19d732b5034c87058260bd04e6 (patch)
tree1518d2aef66c4ffe6e171b596d15e9c94d2194d0 /test/lua
parent13cb93001a2cb7dbf7db85b25ac22558da4f610b (diff)
downloadrspamd-c3896936f524bd19d732b5034c87058260bd04e6.tar.gz
rspamd-c3896936f524bd19d732b5034c87058260bd04e6.zip
Fix tests
Diffstat (limited to 'test/lua')
-rw-r--r--test/lua/unit/redis_stat.lua37
1 files changed, 30 insertions, 7 deletions
diff --git a/test/lua/unit/redis_stat.lua b/test/lua/unit/redis_stat.lua
index f994bdf01..f4e02f5ef 100644
--- a/test/lua/unit/redis_stat.lua
+++ b/test/lua/unit/redis_stat.lua
@@ -1,8 +1,9 @@
-
+
context("Redis statistics unit tests", function()
local task = require("rspamd_task")
local ffi = require("ffi")
+ local rspamd_util = require("rspamd_util")
ffi.cdef[[
struct rspamd_statfile_config {
const char *symbol;
@@ -16,7 +17,7 @@ context("Redis statistics unit tests", function()
struct rspamd_statfile_config *stcf,
struct rspamd_task *task,
char **target);
- struct rspamd_task * rspamd_task_new(struct rspamd_worker *worker);
+ struct rspamd_task * rspamd_task_new(struct rspamd_worker *worker, struct rspamd_config *cfg);
int rspamd_task_add_recipient (struct rspamd_task *task, const char *rcpt);
int rspamd_task_add_sender (struct rspamd_task *task, const char *sender);
]]
@@ -30,14 +31,36 @@ context("Redis statistics unit tests", function()
{"%r%l", "test@example.comlabel"},
{"%f-from", "test@example.com-from"}
}
- local stcf = ffi.new("struct rspamd_statfile_config",
+ local config = {
+ options = {
+ filters = { 'spf', 'dkim', 'regexp' },
+ url_tld = tld_file,
+ dns = {
+ nameserver = { '8.8.8.8' }
+ },
+ },
+ logging = {
+ type = 'console',
+ level = 'debug'
+ },
+ metric = {
+ name = 'default',
+ actions = {
+ reject = 100500,
+ },
+ unknown_weight = 1
+ }
+ }
+ local cfg = rspamd_util.config_from_ucl(config)
+ assert_not_nil(cfg)
+ local stcf = ffi.new("struct rspamd_statfile_config",
{symbol="symbol",label="label"})
- local t = ffi.C.rspamd_task_new(nil)
-
+ local t = ffi.C.rspamd_task_new(nil, cfg)
+
assert_equal(ffi.C.rspamd_task_add_recipient(t, "Test <test@example.com>"), 1)
assert_equal(ffi.C.rspamd_task_add_recipient(t, "Test1 <test1@example.com>"), 1)
assert_equal(ffi.C.rspamd_task_add_sender(t, "Test <test@example.com>"), 1)
-
+
for _,c in ipairs(cases) do
local pbuf = ffi.new 'char *[1]'
local sz = ffi.C.rspamd_redis_expand_object(c[1], stcf, t, pbuf)
@@ -45,4 +68,4 @@ context("Redis statistics unit tests", function()
assert_equal(s, c[2])
end
end)
-end) \ No newline at end of file
+end)