aboutsummaryrefslogtreecommitdiff
path: root/tests.lua
blob: 8033acb93591ad3dcb02eef93483e657b567a511 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env lua

local subscene = require 'server/subscene'
local util = require 'lib/util'

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
        util.error('subscene: fetch failed')
        errs = errs + 1
    end

    if not file_hash_verify(out, sha256) then
        util.error('subscene: hash mismatch')
        errs = errs + 1
    end

    os.remove(out)
end

test_subscene()

if errs == 0  then
    print('ok: all tests ran successfully')
else
    os.exit(false)
end