aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/lua/rspamd_assertions.lua7
-rw-r--r--test/lua/unit/task.lua12
2 files changed, 13 insertions, 6 deletions
diff --git a/test/lua/rspamd_assertions.lua b/test/lua/rspamd_assertions.lua
index da01356ac..ac68cfc0a 100644
--- a/test/lua/rspamd_assertions.lua
+++ b/test/lua/rspamd_assertions.lua
@@ -17,6 +17,10 @@ local function rspamd_assert_table_equals(tbl)
return util.table_cmp(tbl.expect, tbl.actual)
end
+local function rspamd_assert_table_equals_sorted(tbl)
+ return util.table_cmp(table.sort(tbl.expect), table.sort(tbl.actual))
+end
+
local function table_keys_sorted(t)
local keys = {}
@@ -123,3 +127,6 @@ end
telescope.make_assertion("rspamd_eq", rspamd_assert_equals_msg, rspamd_assert_equals)
-- telescope.make_assertion("rspamd_table_eq", rspamd_assert_equals_msg, rspamd_assert_table_equals)
telescope.make_assertion("rspamd_table_eq", rspamd_assert_table_diff_msg, rspamd_assert_table_equals)
+telescope.make_assertion("rspamd_table_eq_sorted", rspamd_assert_table_diff_msg,
+ rspamd_assert_table_equals_sorted)
+
diff --git a/test/lua/unit/task.lua b/test/lua/unit/task.lua
index e9fc9e7d5..0739a2beb 100644
--- a/test/lua/unit/task.lua
+++ b/test/lua/unit/task.lua
@@ -51,7 +51,7 @@ Thank you,
local res,task = rspamd_task.load_from_string(msg)
assert_true(res, "failed to load message")
task:process_message()
- assert_rspamd_table_eq({actual = fun.totable(fun.map(function(u)
+ assert_rspamd_table_eq_sorted({actual = fun.totable(fun.map(function(u)
return u:get_host()
end, task:get_urls())), expect = {
'evil.com', 'example.com'
@@ -65,7 +65,7 @@ Thank you,
local res,task = rspamd_task.load_from_string(msg)
assert_true(res, "failed to load message")
task:process_message()
- assert_rspamd_table_eq({
+ assert_rspamd_table_eq_sorted({
actual = fun.totable(fun.map(function(u)
return u:get_host()
end, task:get_urls())),
@@ -82,7 +82,7 @@ Thank you,
local res,task = rspamd_task.load_from_string(msg)
assert_true(res, "failed to load message")
task:process_message()
- assert_rspamd_table_eq({
+ assert_rspamd_table_eq_sorted({
actual = fun.totable(fun.map(function(u)
return u:get_host()
end, task:get_urls())),
@@ -100,7 +100,7 @@ Thank you,
local res,task = rspamd_task.load_from_string(msg)
assert_true(res, "failed to load message")
task:process_message()
- assert_rspamd_table_eq({
+ assert_rspamd_table_eq_sorted({
actual = fun.totable(fun.map(function(u)
return u:get_host()
end, task:get_urls())),
@@ -122,7 +122,7 @@ Thank you,
local res,task = rspamd_task.load_from_string(msg)
assert_true(res, "failed to load message")
task:process_message()
- assert_rspamd_table_eq({
+ assert_rspamd_table_eq_sorted({
actual = fun.totable(fun.map(function(u)
return u:get_host()
end, task:get_urls())),
@@ -148,7 +148,7 @@ Thank you,
local res,task = rspamd_task.load_from_string(msg)
assert_true(res, "failed to load message")
task:process_message()
- assert_rspamd_table_eq({
+ assert_rspamd_table_eq_sorted({
actual = fun.totable(fun.map(function(u)
return u:get_host()
end, task:get_urls())),