feat(server): boot: migrate, load plugins, worker, scheduler, daily backup, web placeholder
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
6963e297b0
commit
02b7eed5ec
@@ -0,0 +1,22 @@
|
||||
import { expect, test } from "bun:test";
|
||||
import { forEachDialect } from "@sttracker/db/testing";
|
||||
import { ensureBackupScheduled, nextBackupAt } from "../src/boot.ts";
|
||||
|
||||
test("nextBackupAt is the next 03:00 local time", () => {
|
||||
const before = new Date(2026, 9, 30, 2, 59);
|
||||
expect(nextBackupAt(before).getTime()).toBe(new Date(2026, 9, 30, 3, 0).getTime());
|
||||
const after = new Date(2026, 9, 30, 3, 0);
|
||||
expect(nextBackupAt(after).getTime()).toBe(new Date(2026, 9, 31, 3, 0).getTime());
|
||||
});
|
||||
|
||||
forEachDialect("boot", (getDb) => {
|
||||
test("ensureBackupScheduled queues one backup job under lockKey backup", async () => {
|
||||
const db = getDb();
|
||||
expect(await ensureBackupScheduled(db)).not.toBeNull();
|
||||
expect(await ensureBackupScheduled(db)).toBeNull();
|
||||
const jobs = await db.k.selectFrom("jobs").selectAll().where("type", "=", "backup").execute();
|
||||
expect(jobs).toHaveLength(1);
|
||||
expect(jobs[0]).toMatchObject({ lock_key: "backup", status: "queued" });
|
||||
expect(new Date(jobs[0]!.run_at).getHours()).toBe(3);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user