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
- fd8570b1|||PR search: one server exchange per keystrokeTracker
- f5a06a0fLog: gitoria push setup, SR1Tracker
- d6b109baMission SR1mre
- 608b7558Log: FF1 merged via PR #1mre
- 2939d94cMerge branch 'ff1-gate-failfast' into mainTracker
- c934361a|||PR tests: gates fail fast when the app exits during startmre
- d714ae42Log/status: AP56 closed out, FF1mre
- a429d088Mission FF1mre
- 03bbfba3Log: AP56c causemre
- 24845fe3Log: AP56b result, AP56cmre
- 6a6d71eaLog: gitoria membershipmre
- 8b842dc8Log + CONDUCTOR: gitoria PR switch-onmre
- 6bb7c20estatus: window 2026-11-09mre
- 5db84974Log: Apollo window GO, AP56b started, BS1 copy removedmre
- e84586a7Mission AP56bmre
- 15917f03Record PR workflow rule (gitoria#50)mre
- 942ac995status: paused workers statemre
- 44b934e5log: respawn cleanupmre
- 03a80097Log: Anton GC A/Bmre
- c7cdef62Log: Apollo STOP, workers pausedmre