]> source.dussan.org Git - rspamd.git/commitdiff
[Test] Add unit test for get_tld transform + sort test cases
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 13 Sep 2020 22:53:38 +0000 (23:53 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 13 Sep 2020 22:53:38 +0000 (23:53 +0100)
test/lua/unit/selectors.lua

index e65b046c2a8f2556df4d7ed915f3ce54c5be61cf..3367a6df8e5e1d85fa4e7e06bf558ec682f1f04e 100644 (file)
@@ -5,6 +5,7 @@ context("Selectors test", function()
   local lua_selectors = require "lua_selectors"
   local lua_maps = require "lua_maps"
   local test_helper = require "rspamd_test_helper"
+  local lua_util = require "lua_util"
   local cfg = rspamd_config
   local task
 
@@ -226,9 +227,12 @@ context("Selectors test", function()
                 selector = "urls:get_host",
                 expect = {{"subdomain.example.net"}}},
 
-    ["get_tld"] = {
+    ["get_tld_method"] = {
                 selector = "urls:get_tld",
                 expect = {{"example.net"}}},
+    ["get_tld_transform"] = {
+      selector = "urls:get_host.get_tld",
+      expect = {{"example.net"}}},
 
     ["transformation regexp"] = {
                 selector = "urls:get_tld.regexp('\\.([\\w]+)$')",
@@ -356,7 +360,7 @@ context("Selectors test", function()
     },
   }
 
-  for case_name, case in pairs(cases) do
+  for case_name, case in lua_util.spairs(cases) do
     test("case " .. case_name, function()
       local elts = check_selector(case.selector)
       assert_not_nil(elts)