


























@@ -7,7 +7,6 @@ import { migrateLegacyCronRunLogsToSqlite } from "../commands/doctor/cron/legacy
77import {
88appendCronRunLog,
99getPendingCronRunLogWriteCountForTests,
10-readCronRunLogEntries,
1110readCronRunLogEntriesPage,
1211readCronRunLogEntriesSync,
1312resolveCronRunLogPruneOptions,
@@ -201,38 +200,59 @@ describe("cron run log", () => {
201200},
202201});
203202204-const allA = await readCronRunLogEntries({ storePath, jobId: "a", limit: 10 });
203+const allA = (
204+await readCronRunLogEntriesPage({ storePath, jobId: "a", limit: 10, sortDir: "asc" })
205+).entries;
205206expect(allA.map((e) => e.jobId)).toEqual(["a", "a"]);
206207207-const onlyA = await readCronRunLogEntries({
208- storePath,
209-limit: 10,
210-jobId: "a",
211-});
208+const onlyA = (
209+await readCronRunLogEntriesPage({
210+ storePath,
211+limit: 10,
212+jobId: "a",
213+sortDir: "asc",
214+})
215+).entries;
212216expect(onlyA.map((e) => e.ts)).toEqual([1, 3]);
213217214-const lastOne = await readCronRunLogEntries({ storePath, jobId: "a", limit: 1 });
218+const lastOne = (
219+await readCronRunLogEntriesPage({
220+ storePath,
221+jobId: "a",
222+limit: 1,
223+sortDir: "desc",
224+})
225+).entries;
215226expect(lastOne.map((e) => e.ts)).toEqual([3]);
216227expect(lastOne[0]?.sessionId).toBe("run-123");
217228expect(lastOne[0]?.sessionKey).toBe("agent:main:cron:a:run:run-123");
218229219-const onlyB = await readCronRunLogEntries({
220- storePath,
221-limit: 10,
222-jobId: "b",
223-});
230+const onlyB = (
231+await readCronRunLogEntriesPage({
232+ storePath,
233+limit: 10,
234+jobId: "b",
235+sortDir: "asc",
236+})
237+).entries;
224238expect(onlyB[0]?.summary).toBe("oops");
225239226-expect(await readCronRunLogEntries({ storePath, limit: 10, jobId: "missing" })).toStrictEqual(
227-[],
228-);
240+expect(
241+(
242+await readCronRunLogEntriesPage({
243+ storePath,
244+limit: 10,
245+jobId: "missing",
246+sortDir: "asc",
247+})
248+).entries,
249+).toStrictEqual([]);
229250});
230251});
231252232253it("filters run-log pages by runId", async () => {
233254await withRunLogDir("openclaw-cron-log-runid-", async (dir) => {
234255const storePath = storePathForDir(dir);
235-236256await appendCronRunLog({
237257 storePath,
238258entry: {
@@ -302,7 +322,9 @@ describe("cron run log", () => {
302322303323const storePath = storePathForDir(dir);
304324await migrateLegacyCronRunLogsToSqlite(storePath);
305-const entries = await readCronRunLogEntries({ storePath, limit: 10, jobId: "job-1" });
325+const entries = (
326+await readCronRunLogEntriesPage({ storePath, limit: 10, jobId: "job-1", sortDir: "asc" })
327+).entries;
306328expect(entries).toHaveLength(1);
307329expect(entries[0]?.ts).toBe(2);
308330expect(entries[0]?.delivered).toBe(true);
@@ -423,7 +445,9 @@ describe("cron run log", () => {
423445},
424446});
425447426-const entries = await readCronRunLogEntries({ storePath, limit: 10, jobId: "job-1" });
448+const entries = (
449+await readCronRunLogEntriesPage({ storePath, limit: 10, jobId: "job-1", sortDir: "asc" })
450+).entries;
427451expect(entries[0]?.diagnostics?.summary).toBe("exec stderr tail");
428452expect(entries[0]?.diagnostics?.entries).toHaveLength(1);
429453expect(entries[0]?.diagnostics?.entries[0]?.source).toBe("exec");
@@ -483,7 +507,9 @@ describe("cron run log", () => {
483507);
484508485509await migrateLegacyCronRunLogsToSqlite(storePath);
486-const entries = await readCronRunLogEntries({ storePath, limit: 10, jobId: "job-1" });
510+const entries = (
511+await readCronRunLogEntriesPage({ storePath, limit: 10, jobId: "job-1", sortDir: "asc" })
512+).entries;
487513expect(entries[0]?.model).toBe("gpt-5.4");
488514expect(entries[0]?.provider).toBe("openai");
489515expect(entries[0]?.usage).toEqual({
@@ -534,7 +560,14 @@ describe("cron run log", () => {
534560void writePromise.catch(() => undefined);
535561536562// Read should see the entry because it drains pending writes.
537-const entries = await readCronRunLogEntries({ storePath, jobId: "job-drain", limit: 10 });
563+const entries = (
564+await readCronRunLogEntriesPage({
565+ storePath,
566+jobId: "job-drain",
567+limit: 10,
568+sortDir: "asc",
569+})
570+).entries;
538571expect(entries).toHaveLength(1);
539572expect(entries[0]?.ts).toBe(42);
540573expect(entries[0]?.summary).toBe("drain-test");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。