summaryrefslogtreecommitdiffstats
path: root/test/lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-07-16 13:00:51 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-07-16 13:00:51 +0100
commit86069f37686e5709411f1b9e97c0f664dc8a833e (patch)
treec674d91d03bf7721244ea13d68e3a73370c4122a /test/lua
parent5e8eda10b5e40694952d0969bdab430468ea1ba1 (diff)
downloadrspamd-86069f37686e5709411f1b9e97c0f664dc8a833e.tar.gz
rspamd-86069f37686e5709411f1b9e97c0f664dc8a833e.zip
Add html extraction unit test.
Diffstat (limited to 'test/lua')
-rw-r--r--test/lua/unit/html.lua31
-rw-r--r--test/lua/unit/task.lua4
2 files changed, 33 insertions, 2 deletions
diff --git a/test/lua/unit/html.lua b/test/lua/unit/html.lua
new file mode 100644
index 000000000..5c58e209a
--- /dev/null
+++ b/test/lua/unit/html.lua
@@ -0,0 +1,31 @@
+context("HTML processing", function()
+ local rspamd_util = require("rspamd_util")
+ local logger = require("rspamd_logger")
+
+ test("Extract text from HTML", function()
+ local cases = {
+ {[[
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <title>title</title>
+ <link rel="stylesheet" href="style.css">
+ <script src="script.js"></script>
+ </head>
+ <body>
+ <!-- page content -->
+ Hello, world!
+ </body>
+</html>
+ ]], 'Hello, world!'},
+ }
+
+ for _,c in ipairs(cases) do
+ local t = rspamd_util.parse_html(c[1])
+
+ assert_not_nil(t)
+ assert_equal(c[2], tostring(t))
+ end
+ end)
+end) \ No newline at end of file
diff --git a/test/lua/unit/task.lua b/test/lua/unit/task.lua
index ef38c02a3..ed61fb3c5 100644
--- a/test/lua/unit/task.lua
+++ b/test/lua/unit/task.lua
@@ -38,7 +38,7 @@ Content-Type: text/plain
Test.
]]
- local obj = rspamd_util.process_message(cfg, msg)
- print(logger.slog("result: %1", obj))
+ --local obj = rspamd_util.process_message(cfg, msg)
+ --print(logger.slog("result: %1", obj))
end)
end) \ No newline at end of file