From d1b6d08c73600fc0b9a399ee9d4f48ba42492845 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Tue, 16 Jun 2026 10:50:39 -0700 Subject: [PATCH] add tests --- .../integration/backfillLastEvaluatedAt.test.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/server/test/integration/backfillLastEvaluatedAt.test.ts b/server/test/integration/backfillLastEvaluatedAt.test.ts index 53dc6c544..ec0459b7d 100644 --- a/server/test/integration/backfillLastEvaluatedAt.test.ts +++ b/server/test/integration/backfillLastEvaluatedAt.test.ts @@ -47,4 +47,18 @@ describe("0008_backfillMonitorLastEvaluatedAt", () => { const doc = await MonitorModel.collection.findOne({ name: "current" }); expect(doc?.lastEvaluatedAt).toBe(12345); }); + + it("drops the legacy jobs collection left behind by the old scheduler", async () => { + const db = mongoose.connection.db!; + await db.collection("jobs").insertOne({ id: "legacy-job", template: "monitor-job" }); // old-scheduler row + + await backfillMonitorLastEvaluatedAt(); + + const exists = await db.listCollections({ name: "jobs" }).toArray(); + expect(exists).toHaveLength(0); + }); + + it("does not throw when there is no jobs collection to drop", async () => { + await expect(backfillMonitorLastEvaluatedAt()).resolves.toBeUndefined(); + }); });