test: tighten core timestamp assertions · openclaw/openclaw@0fad0a4
steipete
·
2026-05-08
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -295,11 +295,12 @@ describe("message lifecycle primitives", () => {
|
295 | 295 | expect(ctx.shouldAckAfter("receive_record")).toBe(false); |
296 | 296 | expect(ctx.shouldAckAfter("durable_send")).toBe(true); |
297 | 297 | |
| 298 | +const beforeAck = Date.now(); |
298 | 299 | await ctx.ack(); |
299 | 300 | await ctx.ack(); |
300 | 301 | expect(onAck).toHaveBeenCalledTimes(1); |
301 | 302 | expect(ctx.ackState).toBe("acked"); |
302 | | -expect(ctx.ackedAt).toEqual(expect.any(Number)); |
| 303 | +expect(ctx.ackedAt).toBeGreaterThanOrEqual(beforeAck); |
303 | 304 | |
304 | 305 | await ctx.nack(new Error("offset failed")); |
305 | 306 | expect(onNack).toHaveBeenCalledWith(expect.any(Error)); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -61,7 +61,7 @@ describe("cron service store load: missing sessionTarget", () => {
|
61 | 61 | message: "watch dbus", |
62 | 62 | toolsAllow: ["exec"], |
63 | 63 | }); |
64 | | -expect(job.state.nextRunAtMs).toEqual(expect.any(Number)); |
| 64 | +expect(job.state.nextRunAtMs).toBeGreaterThan(STORE_TEST_NOW); |
65 | 65 | expect(assertSupportedJobSpec(job)).toBeUndefined(); |
66 | 66 | }); |
67 | 67 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -134,8 +134,8 @@ describe("diagnostics timeline", () => {
|
134 | 134 | count: 2, |
135 | 135 | }, |
136 | 136 | }); |
137 | | -expect(event?.timestamp).toEqual(expect.any(String)); |
138 | | -expect(event?.pid).toEqual(expect.any(Number)); |
| 137 | +expect(event?.timestamp).toMatch(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/u); |
| 138 | +expect(event?.pid).toBe(process.pid); |
139 | 139 | expect((event?.attributes as Record<string, unknown>).ignored).toBeUndefined(); |
140 | 140 | }); |
141 | 141 | |
@@ -168,7 +168,7 @@ describe("diagnostics timeline", () => {
|
168 | 168 | attributes: { pluginCount: 3 }, |
169 | 169 | }); |
170 | 170 | expect(events[1]?.spanId).toBe(events[0]?.spanId); |
171 | | -expect(events[1]?.durationMs).toEqual(expect.any(Number)); |
| 171 | +expect(events[1]?.durationMs).toBeGreaterThanOrEqual(0); |
172 | 172 | }); |
173 | 173 | |
174 | 174 | it("records span error events and rethrows failures", async () => { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。