aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-04-05 01:58:19 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-04-05 01:58:19 +0100
commit4a67d350b69a99c1aebdedeccca34920dcac205a (patch)
tree7fb0b907ccfaf14c5903923c226d0f7bd55528d8
parentc6cfb1fa571f03fae3fd7e1f274c9b9c24e68174 (diff)
downloadrspamd-4a67d350b69a99c1aebdedeccca34920dcac205a.tar.gz
rspamd-4a67d350b69a99c1aebdedeccca34920dcac205a.zip
Add unit tests for logger.
-rw-r--r--test/lua/unit/logger.lua27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/lua/unit/logger.lua b/test/lua/unit/logger.lua
new file mode 100644
index 000000000..e382ab7e4
--- /dev/null
+++ b/test/lua/unit/logger.lua
@@ -0,0 +1,27 @@
+context("Logger unit tests", function()
+ test("Logger functions", function()
+ local log = require "rspamd_logger"
+
+ local cases = {
+ {'string', 'string'},
+ {'%1', 'string', 'string'},
+ {'%1', '1.100000', 1.1},
+ {'%1', '1', 1},
+ {'%1', 'true', true},
+ {'%1', '{[1] = 1, [2] = test}', {1, 'test'}},
+ {'%1', '{[k1] = 1, [k2] = test}', {k1=1, k2='test'}},
+ {'%1', '{[1] = 1, [2] = 2.100000, [k2] = test}', {1, 2.1, k2='test'}},
+ }
+
+ for _,c in ipairs(cases) do
+ local s
+ if c[3] then
+ s = log.slog(c[1], c[3])
+ else
+ s = log.slog(c[1])
+ end
+ assert_equal(s, c[2], string.format("'%s' doesn't match with '%s'",
+ c[2], s))
+ end
+ end)
+end) \ No newline at end of file