diff options
author | Mikhail Galanin <mgalanin@mimecast.com> | 2018-09-19 15:06:43 +0100 |
---|---|---|
committer | Mikhail Galanin <mgalanin@mimecast.com> | 2018-09-19 15:06:43 +0100 |
commit | f22a82dfc664097b302ca7a95ddde0b304a2ad2b (patch) | |
tree | fecc07b788fd76c6e051cd8cb13e494a79296d46 /test | |
parent | 27689aa22f87406c5216d0e56b42e04e1be5182f (diff) | |
parent | 50d51fca34585b51c1e6ecd168bda6e9e48b0bb2 (diff) | |
download | rspamd-f22a82dfc664097b302ca7a95ddde0b304a2ad2b.tar.gz rspamd-f22a82dfc664097b302ca7a95ddde0b304a2ad2b.zip |
Merge branch 'master' into selectors-test
Diffstat (limited to 'test')
-rw-r--r-- | test/lua/rspamd_assertions.lua | 21 | ||||
-rw-r--r-- | test/lua/tests.lua | 1 |
2 files changed, 22 insertions, 0 deletions
diff --git a/test/lua/rspamd_assertions.lua b/test/lua/rspamd_assertions.lua new file mode 100644 index 000000000..0f2eb3626 --- /dev/null +++ b/test/lua/rspamd_assertions.lua @@ -0,0 +1,21 @@ +local logger = require "rspamd_logger" +local telescope = require "telescope" +local util = require 'lua_util' + +local function rspamd_assert_equals(tbl) + return tbl.expect == tbl.actual +end + +local function rspamd_assert_equals_msg(_, tbl) + return logger.slog( + "Failed asserting that \n (actual) %1 \n equals to\n (expected) %2", + tbl.actual, tbl.expect + ) +end + +local function rspamd_assert_table_equals(tbl) + return util.table_cmp(tbl.expect, tbl.actual) +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) diff --git a/test/lua/tests.lua b/test/lua/tests.lua index 8f64bba4e..99d509de0 100644 --- a/test/lua/tests.lua +++ b/test/lua/tests.lua @@ -1,6 +1,7 @@ -- Run all unit tests in 'unit' directory local telescope = require "telescope" +require "rspamd_assertions" local contexts = {} |