mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 03:20:25 +00:00
test: trim memory hotspot fixture setup
This commit is contained in:
@@ -165,12 +165,6 @@ describe("memory index", () => {
|
||||
indexModelPath = path.join(workspaceDir, "index-model-change.sqlite");
|
||||
indexFtsOnlyPath = path.join(workspaceDir, "index-fts-only.sqlite");
|
||||
sourceChangeStateDir = path.join(fixtureRoot, "state-source-change");
|
||||
|
||||
await fs.mkdir(memoryDir, { recursive: true });
|
||||
await fs.writeFile(
|
||||
path.join(memoryDir, "2026-01-12.md"),
|
||||
"# Log\nAlpha memory line.\nZebra memory line.",
|
||||
);
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
@@ -195,10 +189,12 @@ describe("memory index", () => {
|
||||
providerCalls = [];
|
||||
forceNoProvider = false;
|
||||
|
||||
rmSync(workspaceDir, { recursive: true, force: true });
|
||||
mkdirSync(memoryDir, { recursive: true });
|
||||
|
||||
// Clean additional paths that may have been created by earlier cases.
|
||||
rmSync(extraDir, { recursive: true, force: true });
|
||||
await fs.writeFile(
|
||||
path.join(memoryDir, "2026-01-12.md"),
|
||||
"# Log\nAlpha memory line.\nZebra memory line.",
|
||||
);
|
||||
});
|
||||
|
||||
function resetManagerForTest(manager: MemoryIndexManager) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import fs from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
applyShortTermPromotions,
|
||||
auditShortTermPromotionArtifacts,
|
||||
@@ -17,13 +17,24 @@ import {
|
||||
} from "./short-term-promotion.js";
|
||||
|
||||
describe("short-term promotion", () => {
|
||||
async function withTempWorkspace(run: (workspaceDir: string) => Promise<void>) {
|
||||
const workspaceDir = await fs.mkdtemp(path.join(os.tmpdir(), "memory-promote-"));
|
||||
try {
|
||||
await run(workspaceDir);
|
||||
} finally {
|
||||
await fs.rm(workspaceDir, { recursive: true, force: true });
|
||||
let fixtureRoot = "";
|
||||
let caseId = 0;
|
||||
|
||||
beforeAll(async () => {
|
||||
fixtureRoot = await fs.mkdtemp(path.join(os.tmpdir(), "memory-promote-"));
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
if (!fixtureRoot) {
|
||||
return;
|
||||
}
|
||||
await fs.rm(fixtureRoot, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
async function withTempWorkspace(run: (workspaceDir: string) => Promise<void>) {
|
||||
const workspaceDir = path.join(fixtureRoot, `case-${caseId++}`);
|
||||
await fs.mkdir(workspaceDir, { recursive: true });
|
||||
await run(workspaceDir);
|
||||
}
|
||||
|
||||
async function writeDailyMemoryNote(
|
||||
@@ -1144,7 +1155,7 @@ describe("short-term promotion", () => {
|
||||
return result;
|
||||
});
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 80));
|
||||
await new Promise((resolve) => setTimeout(resolve, 45));
|
||||
expect(settled).toBe(false);
|
||||
|
||||
await fs.unlink(lockPath);
|
||||
|
||||
Reference in New Issue
Block a user