22 lines
1.3 KiB
TypeScript
22 lines
1.3 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { updateScheduleConfig } from "../scheduler";
|
|
|
|
// These tests only exercise the pure validation path in updateScheduleConfig —
|
|
// invalid payloads must throw before any setConfig() call, so they never touch
|
|
// the DB. Valid payloads would hit the DB, so we don't exercise them here.
|
|
describe("updateScheduleConfig validation", () => {
|
|
test("rejects malformed HH:MM start/end", () => {
|
|
expect(() => updateScheduleConfig({ scan: { enabled: true, start: "xx:yy", end: "07:00" } })).toThrow();
|
|
expect(() => updateScheduleConfig({ scan: { enabled: true, start: "1:00", end: "07:00" } })).toThrow();
|
|
expect(() => updateScheduleConfig({ scan: { enabled: true, start: "24:00", end: "07:00" } })).toThrow();
|
|
expect(() => updateScheduleConfig({ process: { enabled: true, start: "01:00", end: "99:99" } })).toThrow();
|
|
});
|
|
|
|
test("rejects non-integer, negative, or out-of-bounds job_sleep_seconds", () => {
|
|
expect(() => updateScheduleConfig({ job_sleep_seconds: Number.NaN })).toThrow();
|
|
expect(() => updateScheduleConfig({ job_sleep_seconds: -1 })).toThrow();
|
|
expect(() => updateScheduleConfig({ job_sleep_seconds: 1.5 })).toThrow();
|
|
expect(() => updateScheduleConfig({ job_sleep_seconds: 86_401 })).toThrow();
|
|
});
|
|
});
|