test: require cron cadence timestamps · openclaw/openclaw@28893ce
steipete
·
2026-05-09
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -21,6 +21,13 @@ function createEveryJob(state: CronJob["state"]): CronJob {
|
21 | 21 | }; |
22 | 22 | } |
23 | 23 | |
| 24 | +function expectTimestamp(value: number | undefined | null, label: string): number { |
| 25 | +if (typeof value !== "number") { |
| 26 | +throw new Error(`Expected ${label} timestamp`); |
| 27 | +} |
| 28 | +return value; |
| 29 | +} |
| 30 | + |
24 | 31 | describe("Cron issue #22895 interval scheduling", () => { |
25 | 32 | it("uses lastRunAtMs cadence when the next interval is still in the future", () => { |
26 | 33 | const nowMs = Date.parse("2026-02-22T10:10:00.000Z"); |
@@ -34,9 +41,9 @@ describe("Cron issue #22895 interval scheduling", () => {
|
34 | 41 | nowMs, |
35 | 42 | ); |
36 | 43 | |
37 | | -expect(nextFromLast).toBe(job.state.lastRunAtMs! + EVERY_30_MIN_MS); |
| 44 | +expect(nextFromLast).toBe(expectTimestamp(job.state.lastRunAtMs, "last run") + EVERY_30_MIN_MS); |
38 | 45 | expect(nextFromAnchor).toBe(Date.parse("2026-02-22T10:14:00.000Z")); |
39 | | -expect(nextFromLast).toBeGreaterThan(nextFromAnchor!); |
| 46 | +expect(nextFromLast).toBeGreaterThan(expectTimestamp(nextFromAnchor, "next anchor run")); |
40 | 47 | }); |
41 | 48 | |
42 | 49 | it("falls back to anchor scheduling when lastRunAtMs cadence is already in the past", () => { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。