gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Main branchmaind2e6d26bMerge branch 'records-park55' into mainTrackermain/tests/tmdbcheck.mjs

3.1 KB

  1. // tests/tmdbcheck.mjs — tools/tmdb-check.hl against a tiny fake TMDB (mission 039, tracker#36): a dropped connection does not end the
  2. // run (asked again at the end, `failed …` line when it still fails), --from N resumes. No real token, no real TMDB.
  3. // COPY=/abs/copy/of/storage/mpackdb TOOL=tools/tmdb-check.hl PORT=8700 node tests/tmdbcheck.mjs (COPY: a copy, never live data)
  4. import http from 'node:http';
  5. import { spawn } from 'node:child_process';
  6. const PORT = Number(process.env.PORT || 8700), COPY = process.env.COPY, TOOL = process.env.TOOL || 'tools/tmdb-check.hl';
  7. if (!COPY) { console.log('set COPY'); process.exit(2); }
  8. let seen = [], dropAlways = null, dropOnce = null, onceDone = false;
  9. const server = http.createServer((req, res) => {
  10. const m = /^\/3\/(movie|tv)\/(\d+)/.exec(req.url); const id = m && m[2];
  11. seen.push(id);
  12. if (id === dropAlways || (id === dropOnce && !onceDone && (onceDone = true))) { req.socket.destroy(); return; }
  13. res.writeHead(200, { 'content-type': 'application/json' });
  14. 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' }));
  15. });
  16. await new Promise(r => server.listen(PORT, '127.0.0.1', r));
  17. const run = (args) => new Promise((resolve) => {
  18. seen = []; onceDone = false; let out = '';
  19. 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 } });
  20. p.stdout.on('data', d => out += d); p.stderr.on('data', d => out += d);
  21. p.on('close', code => resolve({ code, out, seen: [...seen] }));
  22. });
  23. let pass = 0, fail = 0;
  24. const check = (name, ok, extra = '') => { ok ? pass++ : fail++; console.log((ok ? 'PASS ' : 'FAIL ') + name + (ok ? '' : ' — ' + extra)); };
  25. const base = await run(['--limit', '6', '--all']);
  26. const ids = base.seen;
  27. check('baseline: 6 asked, exit 0', ids.length == 6 && base.code == 0, base.out.slice(-300));
  28. dropAlways = ids[1]; dropOnce = ids[2];
  29. const r1 = await run(['--limit', '6', '--all']);
  30. const cnt = (id) => r1.seen.filter(x => x === id).length;
  31. 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));
  32. 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));
  33. const failedLines = r1.out.split('\n').filter(l => l.startsWith('failed '));
  34. 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);
  35. check('totals: clear=5 failed=1 retried=2', /clear=5 errors=0 failed=1 retried=2/.test(r1.out), r1.out.slice(-300));
  36. dropAlways = null;
  37. const r2 = await run(['--from', '4', '--limit', '2']);
  38. 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));
  39. server.close(); console.log(`tmdbcheck: ${pass} pass, ${fail} fail`); process.exit(fail ? 1 : 0);

Branches

Latest commits

  • d2e6d26bMerge branch 'records-park55' into mainTracker
  • f567f025|||PR records: park #55, no Claude workers ruleTracker
  • c21aff6bMerge branch 'records-hm55c' into mainTracker
  • 9ba258d3|||PR records: HM55b resultTracker
  • 64f2d300Merge branch 'records-hm55b2' into mainTracker
  • ae3b80dc|||PR records: HM55b briefTracker
  • 7ef3cb3bMerge branch 'records-st55' into mainTracker
  • fec2e080|||PR records: STATUS HM55Tracker
  • 8e174918Merge branch 'records-hm55b' into mainTracker
  • b1ecee57|||PR records: HM55 stateTracker
  • 28eab08cMerge branch 'records-hm55' into mainTracker
  • d3edaa05|||PR records: HM55 start, PROCEDURES.mdTracker
  • 3059f86cMerge branch 'records-design-rule' into mainTracker
  • 421a4809|||PR records: his-design rule (Apollo 2026-11-13)Tracker
  • d1390692Merge branch 'records-dp75b' into mainTracker
  • a4d1a7d2|||PR records: later steps checked, branch auditTracker
  • e070e16fMerge branch 'records-dp75' into mainTracker
  • 642b4fa8|||PR records: DP75 day62 live, AP62 briefTracker
  • bfc4ea4dMerge branch 'ap62' into mainTracker
  • 2c95ac46|||PR AP62: re-vendor Hybriel set day62 (source 70341ad2, bin a54f5f08)Tracker