]> source.dussan.org Git - rspamd.git/commitdiff
[Test] Use init_url() frim the new helper
authorMikhail Galanin <mgalanin@mimecast.com>
Fri, 21 Sep 2018 08:56:11 +0000 (09:56 +0100)
committerMikhail Galanin <mgalanin@mimecast.com>
Fri, 21 Sep 2018 08:56:11 +0000 (09:56 +0100)
test/lua/unit/lua_util.extract_specific_urls.lua
test/lua/unit/selectors.lua
test/lua/unit/url.lua

index 1eaa88187e03b84ace539842052570fe188dbac4..210e0370cdcd716119874712ff0bd15b920abcd9 100644 (file)
@@ -4,19 +4,11 @@ context("Lua util - extract_specific_urls", function()
   local fun   = require "fun"
   local url   = require "rspamd_url"
   local logger = require "rspamd_logger"
-  local ffi = require "ffi"
   local rspamd_util = require "rspamd_util"
   local rspamd_task = require "rspamd_task"
+  local test_helper = require "rspamd_test_helper"
 
-  ffi.cdef[[
-  void rspamd_url_init (const char *tld_file);
-  unsigned ottery_rand_range(unsigned top);
-  void rspamd_http_normalize_path_inplace(char *path, size_t len, size_t *nlen);
-  ]]
-
-  local test_dir = string.gsub(debug.getinfo(1).source, "^@(.+/)[^/]+$", "%1")
-
-  ffi.C.rspamd_url_init(string.format('%s/%s', test_dir, "test_tld.dat"))
+  test_helper.init_url_parser()
 
   local task_object = {
     urls      = {},
index 5454f35d47b6b1778ce5cb45f0b6ade36ce32186..9b3f950ea818becafb11e18306de1c3a3ce929ad 100644 (file)
@@ -3,20 +3,11 @@ context("Selectors test", function()
   local rspamd_task = require "rspamd_task"
   local logger = require "rspamd_logger"
   local lua_selectors = require "lua_selectors"
-  local ffi = require "ffi"
+  local test_helper = require "rspamd_test_helper"
   local cfg = rspamd_config
-  
   local task
-  
-  ffi.cdef[[
-  void rspamd_url_init (const char *tld_file);
-  unsigned ottery_rand_range(unsigned top);
-  void rspamd_http_normalize_path_inplace(char *path, size_t len, size_t *nlen);
-  ]]
 
-  local test_dir = string.gsub(debug.getinfo(1).source, "^@(.+/)[^/]+$", "%1")
-
-  ffi.C.rspamd_url_init(string.format('%s/%s', test_dir, "test_tld.dat"))
+  test_helper.init_url_parser()
 
   before(function()
     local res
index 902744c2ee74d9beb8803e82dd0c0de947578183..a748c4de870e228dfa886d9272b57bf99f8a4600 100644 (file)
@@ -4,16 +4,14 @@ context("URL check functions", function()
   local mpool = require("rspamd_mempool")
   local url = require("rspamd_url")
   local logger = require("rspamd_logger")
+  local test_helper = require("rspamd_test_helper")
   local ffi = require("ffi")
+
   ffi.cdef[[
-  void rspamd_url_init (const char *tld_file);
-  unsigned ottery_rand_range(unsigned top);
   void rspamd_http_normalize_path_inplace(char *path, size_t len, size_t *nlen);
   ]]
 
-  local test_dir = string.gsub(debug.getinfo(1).source, "^@(.+/)[^/]+$", "%1")
-
-  ffi.C.rspamd_url_init(string.format('%s/%s', test_dir, "test_tld.dat"))
+  test_helper.init_url_parser()
 
   local pool = mpool.create()