Cover Polar and Oura sync queues in the dead-queue guard

Only the Nightscout sync queue was asserted in allQueues; the two OAuth-
wearable polls shipped alongside it carry the same v1.4.37 dead-queue risk.
Assert POLAR_SYNC_QUEUE and OURA_SYNC_QUEUE membership, cron, and handler
wiring so a future refactor can't silently drop one.
This commit is contained in:
Marc-André Bombeck committed 2026-06-14 20:59:58 +02:00
1 parent cf76e6f5ea
commit ef36a6a81f
1 file changed
+43 -7
@@ -1,15 +1,13 @@
/**
* v1.17.0 — pg-boss queue registration for the Nightscout CGM sync layer.
* v1.17.0 — pg-boss queue registration for the three new poll-only sync layers:
* Nightscout CGM, Polar, and Oura.
*
* Source-as-text guard (the reminder-worker pulls heavy infra we don't boot
* here): assert the queue constant + cron + handler wiring + allQueues
* here): assert each queue constant + cron + handler wiring + allQueues
* membership are present — the fast guard against the v1.4.37 dead-queue class
* (a queue declared but never registered in `allQueues`, which silently never
* drains).
*
* Nightscout is poll-only (no webhook, no OAuth, no backfill queue): a single
* hourly `nightscout-sync` tick walks every configured instance via
* `syncUserNightscout`.
* drains). All three syncs are poll-only (no webhook, no backfill queue): a
* single hourly tick walks every configured account.
*/
import { readFileSync } from "node:fs";
import { join } from "node:path";
@@ -45,3 +43,41 @@ describe("reminder-worker — Nightscout sync queue", () => {
);
});
});
describe("reminder-worker — Polar / Oura sync queues", () => {
// The same v1.4.37 dead-queue class applies to the two OAuth-wearable polls
// shipped alongside Nightscout in v1.17.0 — assert their allQueues membership
// so a future refactor can't silently drop one and starve the sync.
const allQueuesBlock = () => {
const block = /const allQueues = \[([\s\S]*?)\];/.exec(source);
expect(block).not.toBeNull();
return block![1]!;
};
it("declares the polar-sync and oura-sync queue constants", () => {
expect(source).toMatch(/POLAR_SYNC_QUEUE\s*=\s*["']polar-sync["']/);
expect(source).toMatch(/OURA_SYNC_QUEUE\s*=\s*["']oura-sync["']/);
});
it("registers POLAR_SYNC_QUEUE in allQueues (v1.4.37 dead-queue guard)", () => {
expect(allQueuesBlock()).toContain("POLAR_SYNC_QUEUE");
});
it("registers OURA_SYNC_QUEUE in allQueues (v1.4.37 dead-queue guard)", () => {
expect(allQueuesBlock()).toContain("OURA_SYNC_QUEUE");
});
it("schedules the hourly poll cron for both", () => {
expect(source).toMatch(/\[POLAR_SYNC_QUEUE,\s*POLAR_SYNC_CRON\]/);
expect(source).toMatch(/\[OURA_SYNC_QUEUE,\s*OURA_SYNC_CRON\]/);
});
it("registers a boss.work handler for each queue", () => {
expect(source).toMatch(
/boss\.work[\s\S]{0,160}POLAR_SYNC_QUEUE[\s\S]{0,160}handlePolarSync/,
);
expect(source).toMatch(
/boss\.work[\s\S]{0,160}OURA_SYNC_QUEUE[\s\S]{0,160}handleOuraSync/,
);
});
});