diff options
author | sinanmohd <sinan@sinanmohd.com> | 2023-09-29 18:02:59 +0530 |
---|---|---|
committer | sinanmohd <sinan@sinanmohd.com> | 2023-09-30 14:52:39 +0530 |
commit | 05a9be65f8e0d97fd36711acfe5d626e316722ae (patch) | |
tree | d00771702c4628f8d27297938ebfbdb924541a58 /tests.lua |
repo: init
Diffstat (limited to 'tests.lua')
-rwxr-xr-x | tests.lua | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests.lua b/tests.lua new file mode 100755 index 0000000..feadb75 --- /dev/null +++ b/tests.lua @@ -0,0 +1,36 @@ +#!/usr/bin/env lua + +local subscene = require 'server/subscene' + +local errs = 0 + +local file_hash_verify = function (path, sha256) + local newhash = io.popen('sha256sum ' .. path):read(64) + return (newhash == sha256) +end + +local test_subscene = function () + local out, sha256, name + + out = os.tmpname() + name = 'Fight Club (1999) (1080p BluRay x265 10bit Tigole) [QxR].mp4' + sha256 = 'fe88e2c1345a7daed82cb570952c13fae6a6867449f7dd5e719ea0a0c1e2e242' + + if not subscene.search(name, out) then + print('err: subscene: failed to fetch subtitles') + errs = errs + 1 + end + + if not file_hash_verify(out, sha256) then + print('err: subscene: subtitle hash mismatch') + errs = errs + 1 + end + + os.remove(out) +end + +test_subscene() + +if errs == 0 then + print('ok: all tests ran successfully') +end |