commit bed1734: [Test] Update unit tests

Vsevolod Stakhov vsevolod at highsecure.ru
Mon Aug 19 15:56:20 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-08-19 16:49:31 +0100
URL: https://github.com/rspamd/rspamd/commit/bed17348687c6211f9fe0c5965e7d7ed4008bc20 (HEAD -> master)

[Test] Update unit tests

---
 test/lua/unit/lua_util.extract_specific_urls.lua | 16 +++++++++++-----
 test/lua/unit/selectors.lua                      |  2 +-
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/test/lua/unit/lua_util.extract_specific_urls.lua b/test/lua/unit/lua_util.extract_specific_urls.lua
index 1e00524d0..93816745e 100644
--- a/test/lua/unit/lua_util.extract_specific_urls.lua
+++ b/test/lua/unit/lua_util.extract_specific_urls.lua
@@ -45,8 +45,8 @@ context("Lua util - extract_specific_urls", function()
   local cases = {
     {expect = url_list, filter = nil, limit = 9999, need_emails = true, prefix = 'p'},
     {expect = {}, filter = (function() return false end), limit = 9999, need_emails = true, prefix = 'p'},
-    {expect = {"domain4.co.net", "test.com"}, filter = nil, limit = 2, need_emails = true, prefix = 'p'},
-    {expect = {"domain4.co.net", "test.com", "domain3.org"}, filter = nil, limit = 3, need_emails = true, prefix = 'p'},
+    {expect = {"tesco.co.net", "test.com"}, filter = nil, limit = 2, need_emails = true, prefix = 'p'},
+    {expect = {"tesco.co.net", "test.com", "meet.org"}, filter = nil, limit = 3, need_emails = true, prefix = 'p'},
     {
       expect = {"gov.co.net", "tesco.co.net", "domain1.co.net", "domain2.co.net", "domain3.co.net", "domain4.co.net"},
       filter = (function(s) return s:get_host():sub(-4) == ".net" end),
@@ -65,7 +65,7 @@ context("Lua util - extract_specific_urls", function()
     },
     {
       input  = {"abc at a.google.com", "b.google.com", "c.google.com", "a.net", "bb.net", "a.bb.net", "b.bb.net"},
-      expect = {"abc at a.google.com", "a.bb.net", "b.google.com", "a.net", "bb.net", "abc at a.google.com"},
+      expect = {"abc at a.google.com", "a.bb.net", "b.google.com", "a.net", "bb.net"},
       filter = nil,
       limit = 9999,
       esld_limit = 2,
@@ -105,6 +105,8 @@ context("Lua util - extract_specific_urls", function()
         local s = logger.slog("%1 =?= %2", c.expect, actual_result)
         print(s) --]]
 
+      table.sort(actual_result)
+      table.sort(c.expect)
       assert_rspamd_table_eq({actual = actual_result, expect = c.expect})
     end)
 
@@ -126,6 +128,8 @@ context("Lua util - extract_specific_urls", function()
         local s = logger.slog("case[%1] %2 =?= %3", i, c.expect, actual_result)
         print(s) --]]
 
+      table.sort(actual_result)
+      table.sort(c.expect)
       assert_rspamd_table_eq({actual = actual_result, expect = c.expect})
     end)
   end
@@ -135,12 +139,14 @@ context("Lua util - extract_specific_urls", function()
     local actual = util.extract_specific_urls(task_object, 3, true)
 
     local actual_result = prepare_actual_result(actual)
-    table.sort(actual_result)
     --[[
       local s = logger.slog("%1 =?= %2", c.expect, actual_result)
       print(s) --]]
 
-    assert_rspamd_table_eq({actual = actual_result, expect = {"abc.com", "abc.net", "abc.za.org"}})
+    local expect = {"abc.com", "abc.net", "abc.za.org"}
+    table.sort(actual_result)
+    table.sort(expect)
+    assert_rspamd_table_eq({actual = actual_result, expect = expect})
   end)
 
 
diff --git a/test/lua/unit/selectors.lua b/test/lua/unit/selectors.lua
index 924c94c48..b528ea9fb 100644
--- a/test/lua/unit/selectors.lua
+++ b/test/lua/unit/selectors.lua
@@ -161,7 +161,7 @@ context("Selectors test", function()
 
     ["specific_urls + emails limit"] = {
       selector = "specific_urls({need_emails = true, limit = 1})",
-      expect = {{"http://example.net"}}},
+      expect = {{"mailto://test@example.net"}}},
 
     ["pool_var str, default type"] = {
                 selector = [[pool_var("str_var")]],


More information about the Commits mailing list