From 7450e13517888bfaef257127fa2fadaf0ab5de40 Mon Sep 17 00:00:00 2001 From: Abdel Fane <32418586+thebenignhacker@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:33:36 -0600 Subject: [PATCH] test: the last-measured-counts test seeds its own model instead of asserting the committed counts The test required the committed database's top Hugging Face model to have non-zero newest counts, so it fails on main now that this model's newest snapshot holds a measured 30-day count of 0, which is a valid data value and not a code defect. The test now inserts its own model with two measured snapshots of fixed non-zero counts and runs every later assertion against that model, so the committed rows' values no longer decide the result. --- test/huggingface.test.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/test/huggingface.test.js b/test/huggingface.test.js index 8f954a243..2466210b1 100644 --- a/test/huggingface.test.js +++ b/test/huggingface.test.js @@ -231,16 +231,15 @@ test('the API route and the overview keep each model\'s last measured counts, an const db = committedCopy(); try { migrateHuggingfaceStats(db); - const target = db.prepare(` - SELECT model_id AS id, MAX(date) AS last FROM huggingface_stats - GROUP BY model_id ORDER BY MAX(downloads_all_time) DESC LIMIT 1 - `).get(); - const measured = db.prepare(` - SELECT downloads_all_time AS downloadsAllTime, downloads_30d AS downloads30d, likes - FROM huggingface_stats WHERE model_id = ? AND date = ? - `).get(target.id, target.last); - assert.ok(measured.downloadsAllTime > 0 && measured.downloads30d > 0 && measured.likes > 0, - 'the committed database has a model with non-zero counts'); + // The committed snapshot may hold a model whose newest counts are null or 0, so the test measures a model of its own. + db.prepare("INSERT INTO huggingface_models (model_id, author) VALUES ('fixture/last-measured-counts', 'fixture')").run(); + const target = db.prepare("SELECT id FROM huggingface_models WHERE model_id = 'fixture/last-measured-counts'").get(); + const snapshot = db.prepare(` + INSERT INTO huggingface_stats (model_id, date, downloads_30d, downloads_all_time, likes) VALUES (?, ?, ?, ?, ?) + `); + snapshot.run(target.id, '2026-01-01', 300, 1200, 4); // an earlier measured day, so the period growth is 50, not 0 + const measured = { downloadsAllTime: 1250, downloads30d: 320, likes: 5 }; + snapshot.run(target.id, '2026-01-02', measured.downloads30d, measured.downloadsAllTime, measured.likes); const baseEntry = huggingfaceModelList(db).find(m => m.id === target.id); const baseDetail = huggingfaceModelDetail(db, target.id, '0000-00-00'); const baseOverview = computeOverview(db, {});