tracker
All repositories: gitoria
3.1 KB
// tests/tmdbcheck.mjs — tools/tmdb-check.hl against a tiny fake TMDB (mission 039, tracker#36): a dropped connection does not end the// run (asked again at the end, `failed …` line when it still fails), --from N resumes. No real token, no real TMDB.// COPY=/abs/copy/of/storage/mpackdb TOOL=tools/tmdb-check.hl PORT=8700 node tests/tmdbcheck.mjs (COPY: a copy, never live data)import http from 'node:http';import { spawn } from 'node:child_process';const PORT = Number(process.env.PORT || 8700), COPY = process.env.COPY, TOOL = process.env.TOOL || 'tools/tmdb-check.hl';if (!COPY) { console.log('set COPY'); process.exit(2); }let seen = [], dropAlways = null, dropOnce = null, onceDone = false;const server = http.createServer((req, res) => {const m = /^\/3\/(movie|tv)\/(\d+)/.exec(req.url); const id = m && m[2];seen.push(id);if (id === dropAlways || (id === dropOnce && !onceDone && (onceDone = true))) { req.socket.destroy(); return; }res.writeHead(200, { 'content-type': 'application/json' });res.end(JSON.stringify({ id: Number(id), title: 'x', name: 'x', original_title: 'x', original_name: 'x', release_date: '1999-01-01', first_air_date: '1999-01-01' }));});await new Promise(r => server.listen(PORT, '127.0.0.1', r));const run = (args) => new Promise((resolve) => {seen = []; onceDone = false; let out = '';const p = spawn('./bin/hybriel', [TOOL, ...args], { env: { ...process.env, TMDB_READ_TOKEN: 'fake-token', TMDB_BASE_URL: `http://127.0.0.1:${PORT}/3`, TRACKER_STORAGE: COPY } });p.stdout.on('data', d => out += d); p.stderr.on('data', d => out += d);p.on('close', code => resolve({ code, out, seen: [...seen] }));});let pass = 0, fail = 0;const check = (name, ok, extra = '') => { ok ? pass++ : fail++; console.log((ok ? 'PASS ' : 'FAIL ') + name + (ok ? '' : ' — ' + extra)); };const base = await run(['--limit', '6', '--all']);const ids = base.seen;check('baseline: 6 asked, exit 0', ids.length == 6 && base.code == 0, base.out.slice(-300));dropAlways = ids[1]; dropOnce = ids[2];const r1 = await run(['--limit', '6', '--all']);const cnt = (id) => r1.seen.filter(x => x === id).length;check('run goes on after dropped connections (exit 0, done line)', r1.code == 0 && /tmdb check done: asked=6/.test(r1.out), r1.out.slice(-400));check('dropped-once title asked again, then ok', cnt(ids[2]) == 2 && cnt(ids[1]) == 2 && ids.slice(3).every(i => cnt(i) == 1), JSON.stringify(r1.seen));const failedLines = r1.out.split('\n').filter(l => l.startsWith('failed '));check('exactly one `failed` line, with the reason, for the title that kept failing', failedLines.length == 1 && failedLines[0].includes('tmdb ' + ids[1] + ':') && /no answer/.test(failedLines[0]), r1.out);check('totals: clear=5 failed=1 retried=2', /clear=5 errors=0 failed=1 retried=2/.test(r1.out), r1.out.slice(-300));dropAlways = null;const r2 = await run(['--from', '4', '--limit', '2']);check('--from 4 --limit 2 asks exactly titles 5 and 6 of the same order', JSON.stringify(r2.seen) == JSON.stringify(ids.slice(4, 6)), JSON.stringify(r2.seen));server.close(); console.log(`tmdbcheck: ${pass} pass, ${fail} fail`); process.exit(fail ? 1 : 0);
Branches
Latest commits
- 4399bc2fReference remaining component-owned root Style rulesmre
- aed12917Reference owned Style rules in genres and searchmre
- 78ee6b56Move remaining component styles into Style blocksmre
- 7f04de33log: HM49Bmre
- 00616cf3log: #49 batch merged, DP67 startedmre
- d7232e86Merge hm49-styles: tracker#49 first batch of component stylesmre
- 079f376dMove seven components' styles into Style blocksmre
- 17d66feelog: #58 mergedmre
- 69a6640bMerge hm58-map: tracker#58 project.hl only the mapmre
- a85f7900Move route logic out of the project mapmre
- 13dea5belog: #56 live, HM49 and HM58 startedmre
- a31c8f2fdocs: tracker#36 remaining listmre
- 975d06d1log: #36 live, DP66 startedmre
- d6d03fa3mission: T36Bmre
- e7512d00status: #36 rolled back, retry askedmre
- c98e2043log: T36A rollbackmre
- ae905f15Merge t36a: tracker#36 apply rechecks, reportmre
- 796bfaceT36A: report validated fixes, failed live SSH check and verified rollbackmre
- 55257852log: #53 live, #56 mergedmre
- 78b39f1bMerge hm56-rows: tracker#56 list builders insert oncemre