commit 8b74a6d: [Minor] Test: Sort tables when asserting

Vsevolod Stakhov vsevolod at highsecure.ru
Mon Jul 6 10:56:07 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-07-06 11:50:53 +0100
URL: https://github.com/rspamd/rspamd/commit/8b74a6dd2e8bb5ae4651b0b42369be86f21383ae (HEAD -> master)

[Minor] Test: Sort tables when asserting

---
 test/lua/unit/lua_util.extract_specific_urls.lua | 26 +++++++++---------------
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/test/lua/unit/lua_util.extract_specific_urls.lua b/test/lua/unit/lua_util.extract_specific_urls.lua
index 8e225b8fa..71c83e35c 100644
--- a/test/lua/unit/lua_util.extract_specific_urls.lua
+++ b/test/lua/unit/lua_util.extract_specific_urls.lua
@@ -161,9 +161,7 @@ context("Lua util - extract_specific_urls plain", 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})
+      assert_rspamd_table_eq_sorted({actual = actual_result, expect = c.expect})
     end)
 
     test("extract_specific_urls " .. i, function()
@@ -184,9 +182,7 @@ context("Lua util - extract_specific_urls plain", 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})
+      assert_rspamd_table_eq_sorted({actual = actual_result, expect = c.expect})
     end)
   end
 
@@ -200,9 +196,7 @@ context("Lua util - extract_specific_urls plain", function()
       print(s) --]]
 
     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})
+    assert_rspamd_table_eq_sorted({actual = actual_result, expect = expect})
   end)
 end)
 
@@ -257,7 +251,7 @@ context("Lua util - extract_specific_urls message", function()
       local s = logger.slog("case[%1] %2 =?= %3", i, expect, actual_result)
       print(s) --]]
 
-    assert_rspamd_table_eq({actual = actual_result, expect = {"domain.com"}})
+    assert_rspamd_table_eq_sorted({actual = actual_result, expect = {"domain.com"}})
 
   end)
   test("extract_specific_urls - from email 2 limit", function()
@@ -273,7 +267,7 @@ context("Lua util - extract_specific_urls message", function()
       local s = logger.slog("case[%1] %2 =?= %3", i, expect, actual_result)
       print(s) --]]
 
-    assert_rspamd_table_eq({actual = actual_result, expect = {"domain.com", "example.net"}})
+    assert_rspamd_table_eq_sorted({actual = actual_result, expect = {"domain.com", "example.net"}})
 
   end)
 
@@ -300,7 +294,7 @@ context("Lua util - extract_specific_urls message", function()
       local s = logger.slog("case[%1] %2 =?= %3", i, expect, actual_result)
       print(s) --]]
 
-    assert_rspamd_table_eq({actual = actual_result, expect = {"domain.com"}})
+    assert_rspamd_table_eq_sorted({actual = actual_result, expect = {"domain.com"}})
 
   end)
   test("extract_specific_urls - from email image 2 limit", function()
@@ -317,7 +311,7 @@ context("Lua util - extract_specific_urls message", function()
       local s = logger.slog("case[%1] %2 =?= %3", i, expect, actual_result)
       print(s) --]]
 
-    assert_rspamd_table_eq({actual = actual_result, expect = {"domain.com", "example.net"}})
+    assert_rspamd_table_eq_sorted({actual = actual_result, expect = {"domain.com", "example.net"}})
 
   end)
   test("extract_specific_urls - from email image 3 limit, no images", function()
@@ -334,7 +328,7 @@ context("Lua util - extract_specific_urls message", function()
       local s = logger.slog("case[%1] %2 =?= %3", i, expect, actual_result)
       print(s) --]]
 
-    assert_rspamd_table_eq({actual = actual_result, expect = {"domain.com", "example.net"}})
+    assert_rspamd_table_eq_sorted({actual = actual_result, expect = {"domain.com", "example.net"}})
   end)
   test("extract_specific_urls - from email image 3 limit, has images", function()
     local actual = util.extract_specific_urls({
@@ -350,7 +344,7 @@ context("Lua util - extract_specific_urls message", function()
       local s = logger.slog("case[%1] %2 =?= %3", i, expect, actual_result)
       print(s) --]]
 
-    assert_rspamd_table_eq({actual = actual_result,
+    assert_rspamd_table_eq_sorted({actual = actual_result,
                             expect = {"domain.com", "example.net", "example5.org"}})
   end)
   test("extract_specific_urls - from email image 2 limit, has images", function()
@@ -367,7 +361,7 @@ context("Lua util - extract_specific_urls message", function()
       local s = logger.slog("case[%1] %2 =?= %3", i, expect, actual_result)
       print(s) --]]
 
-    assert_rspamd_table_eq({actual = actual_result,
+    assert_rspamd_table_eq_sorted({actual = actual_result,
                             expect = {"domain.com", "example.net"}})
   end)
 end)


More information about the Commits mailing list