From: Vsevolod Stakhov Date: Fri, 19 Jul 2019 12:41:39 +0000 (+0100) Subject: [Test] Add tests for maps in selectors X-Git-Tag: 2.0~542 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8f0370ca239e47796fc42f1abc4efc16231b99f2;p=rspamd.git [Test] Add tests for maps in selectors --- 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