]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Add html extraction unit test.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 16 Jul 2015 12:00:51 +0000 (13:00 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 16 Jul 2015 12:00:51 +0000 (13:00 +0100)
test/lua/unit/html.lua [new file with mode: 0644]
test/lua/unit/task.lua

diff --git a/test/lua/unit/html.lua b/test/lua/unit/html.lua
new file mode 100644 (file)
index 0000000..5c58e20
--- /dev/null
@@ -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
index ef38c02a31b4bd619a5c4dee6eccccea70f2716c..ed61fb3c5695ce09ac1642af1aebb1f2e83e4fbc 100644 (file)
@@ -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