aboutsummaryrefslogtreecommitdiffstats
path: root/test/lua/unit
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-07-19 13:41:39 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-07-19 13:41:39 +0100
commit8f0370ca239e47796fc42f1abc4efc16231b99f2 (patch)
tree4233ddf23b122b4230c5f4107a22cba9bf6086c3 /test/lua/unit
parentf7a044a1cb297b891af84e6cefae32217e97c300 (diff)
downloadrspamd-8f0370ca239e47796fc42f1abc4efc16231b99f2.tar.gz
rspamd-8f0370ca239e47796fc42f1abc4efc16231b99f2.zip
[Test] Add tests for maps in selectors
Diffstat (limited to 'test/lua/unit')
-rw-r--r--test/lua/unit/selectors.lua17
1 files changed, 16 insertions, 1 deletions
diff --git a/test/lua/unit/selectors.lua b/test/lua/unit/selectors.lua
index d4450707b..0aba4d663 100644
--- a/test/lua/unit/selectors.lua
+++ b/test/lua/unit/selectors.lua
@@ -3,12 +3,18 @@ context("Selectors test", function()
local rspamd_task = require "rspamd_task"
local logger = require "rspamd_logger"
local lua_selectors = require "lua_selectors"
+ local lua_maps = require "lua_maps"
local test_helper = require "rspamd_test_helper"
local cfg = rspamd_config
local task
test_helper.init_url_parser()
+ lua_selectors.maps.test_map = lua_maps.map_add_from_ucl({
+ 'key value',
+ 'key1 value1',
+ }, 'hash', 'test selectors maps')
+
before(function()
local res
res,task = rspamd_task.load_from_string(msg, cfg)
@@ -238,7 +244,16 @@ context("Selectors test", function()
["transformation substring -4"] = {
selector = "header(Subject, strong).substring(-4)",
- expect = {'ject'}},
+ expect = {'ject'}
+ },
+ ["map filter"] = {
+ selector = "id('key').filter_map(test_map)",
+ expect = {'key'}
+ },
+ ["map apply"] = {
+ selector = "id('key').apply_map(test_map)",
+ expect = {'value'}
+ },
}
for case_name, case in pairs(cases) do