mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 04:51:25 +00:00
test: dedupe shared setup in channel and doctor config tests
This commit is contained in:
@@ -15,6 +15,24 @@ installCronTestHooks({
|
||||
baseTimeIso: "2026-02-06T17:00:00.000Z",
|
||||
});
|
||||
|
||||
function createStartedCron(storePath: string) {
|
||||
const cron = new CronService({
|
||||
storePath,
|
||||
cronEnabled: true,
|
||||
log: noopLogger,
|
||||
enqueueSystemEvent: vi.fn(),
|
||||
requestHeartbeatNow: vi.fn(),
|
||||
runIsolatedAgentJob: vi.fn(async () => ({ status: "ok" as const, summary: "ok" })),
|
||||
});
|
||||
return {
|
||||
cron,
|
||||
start: async () => {
|
||||
await cron.start();
|
||||
return cron;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
describe("CronService store migrations", () => {
|
||||
it("migrates legacy top-level agentTurn fields and initializes missing state", async () => {
|
||||
const store = await makeStorePath();
|
||||
@@ -52,16 +70,7 @@ describe("CronService store migrations", () => {
|
||||
"utf-8",
|
||||
);
|
||||
|
||||
const cron = new CronService({
|
||||
storePath: store.storePath,
|
||||
cronEnabled: true,
|
||||
log: noopLogger,
|
||||
enqueueSystemEvent: vi.fn(),
|
||||
requestHeartbeatNow: vi.fn(),
|
||||
runIsolatedAgentJob: vi.fn(async () => ({ status: "ok" as const, summary: "ok" })),
|
||||
});
|
||||
|
||||
await cron.start();
|
||||
const cron = await createStartedCron(store.storePath).start();
|
||||
|
||||
const status = await cron.status();
|
||||
expect(status.enabled).toBe(true);
|
||||
@@ -132,16 +141,7 @@ describe("CronService store migrations", () => {
|
||||
"utf-8",
|
||||
);
|
||||
|
||||
const cron = new CronService({
|
||||
storePath: store.storePath,
|
||||
cronEnabled: true,
|
||||
log: noopLogger,
|
||||
enqueueSystemEvent: vi.fn(),
|
||||
requestHeartbeatNow: vi.fn(),
|
||||
runIsolatedAgentJob: vi.fn(async () => ({ status: "ok" as const, summary: "ok" })),
|
||||
});
|
||||
|
||||
await cron.start();
|
||||
const cron = await createStartedCron(store.storePath).start();
|
||||
|
||||
const jobs = await cron.list({ includeDisabled: true });
|
||||
const job = jobs.find((entry) => entry.id === "legacy-agentturn-no-timeout");
|
||||
|
||||
Reference in New Issue
Block a user