gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit6e951d916e951d91AP52: show-page rows are keyed records; closing a season is one upsert and removes (tracker#56, hybriel#331)mre6e951d91/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

  • 6e951d91AP52: show-page rows are keyed records; closing a season is one upsert and removes (tracker#56, hybriel#331)mre
  • 3bb4ccddAP52: modal close button refers to its nested rule with Style.buttonModalX (tracker#51, hybriel#333)mre
  • ba16933fAP52: login callback and title route are static handlers taking the server as third argument (tracker#58, hybriel#332)mre
  • 85153900AP52: re-vendor Hybriel set day52 (source 77cfca31, bin 0a8ed496)mre
  • 7c051eddLog: hybriel#338 answermre
  • d049b8b8Log: HM50 live, #52 donemre
  • 6d05fa37Log: HM50 Part A mergedmre
  • 1c7dab74HM50: the shell reads the framework's online state, netProbe removed (tracker#55)mre
  • e8b91697HM50: search address follows the text via navigate(path, replace = true) (tracker#52)mre
  • 6fe1896cHM50: re-vendor Hybriel set day50 (source 0ae38232, bin d3ef9d16)mre
  • 2f391aa9Log: HM50 startedmre
  • 4b59c03dHM50 mission: doc pathmre
  • ed526d67HM50 missionmre
  • 2f986ca3Log: RT50 passmre
  • 1c4715a4RT50 mission: day50 repro retestmre
  • 57d1c0dcLog: day50 retest requestmre
  • 60b1f419Log: Anton #336 result, wake checkmre
  • 919a18aalog: scratchmre
  • 6b504440status tidymre
  • 9332bd10log: DP70 livemre