aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsinanmohd <sinan@sinanmohd.com>2024-03-04 21:58:34 +0530
committersinanmohd <sinan@sinanmohd.com>2024-03-04 23:57:53 +0530
commitf43cd4c508e5f90a35cace9ef3c97586ba7c1967 (patch)
tree63b670dce04834976b0dd1eb01f897cae810a2b7
parentc6c93fcd02581d56a9ca21729e491dba2afe3352 (diff)
tests: refactor
-rwxr-xr-xtests.lua40
1 files changed, 22 insertions, 18 deletions
diff --git a/tests.lua b/tests.lua
index a9803f8..5520bcb 100755
--- a/tests.lua
+++ b/tests.lua
@@ -1,31 +1,35 @@
#!/usr/bin/env lua
local opensubtitles = require 'server.opensubtitles'
-local util = require 'lib.util'
-local errs = 0
+local note = function (success, name)
+ local sign
+
+ if success then
+ sign = '✅'
+ else
+ sign = '❌'
+ end
+
+ print(sign .. ' : ' .. name)
+end
+
local test_opensubtitles = function ()
- local ohash, name, id, new_id
+ local ohash, name, id
ohash = '395787dbe5b42001'
name = 'Fight.Club.1999.REMASTERED.720p.BRRip.XviD.AC3-RARBG'
- id = '5449593'
- new_id = opensubtitles.search_ohash(ohash, name)
- if new_id then
- new_id = new_id:match('%d*$')
- end
+ id = opensubtitles.search_ohash(ohash, name, 'eng')
+ note(id and id:match('%d+$') == '5449593', 'search_ohash')
- if id ~= new_id then
- util.error('opensubtitles: id mismatch')
- errs = errs + 1
- end
+ name = 'Fight.Club.10th.Anniversary.Edition.1999.720p.BrRip.x264.YIFY'
+ id = opensubtitles.search_filesize(1074575924, name, 'eng')
+ note(id and id:match('%d+$') == '4987774', 'search_filesize')
+
+ name = 'Fight.Club.1999.REMASTERED.720p.BRRip.XviD.AC3-RARBG'
+ id = opensubtitles.search_name(name, 'eng')
+ note(id and id:match('%d+$') == '5449593', 'search_name')
end
test_opensubtitles()
-
-if errs == 0 then
- print('ok: all tests ran successfully')
-else
- os.exit(false)
-end