commit 8f0370c: [Test] Add tests for maps in selectors

Vsevolod Stakhov vsevolod at highsecure.ru
Fri Jul 19 12:56:08 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-07-19 13:41:39 +0100
URL: https://github.com/rspamd/rspamd/commit/8f0370ca239e47796fc42f1abc4efc16231b99f2

[Test] Add tests for maps in selectors

---
 test/lua/unit/selectors.lua | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

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


More information about the Commits mailing list