mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 04:40:42 +00:00
test: simplify session compact line count
This commit is contained in:
@@ -11,6 +11,16 @@ import {
|
||||
|
||||
const { createSessionStoreDir, openClient } = setupGatewaySessionsTestHarness();
|
||||
|
||||
function collectNonEmptyLines(text: string): string[] {
|
||||
const lines: string[] = [];
|
||||
for (const line of text.split(/\r?\n/)) {
|
||||
if (line.trim().length > 0) {
|
||||
lines.push(line);
|
||||
}
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
test("lists and patches session store via sessions.* RPC", async () => {
|
||||
const { dir, storePath } = await createSessionStoreDir();
|
||||
const now = Date.now();
|
||||
@@ -378,9 +388,9 @@ test("lists and patches session store via sessions.* RPC", async () => {
|
||||
});
|
||||
expect(compacted.ok).toBe(true);
|
||||
expect(compacted.payload?.compacted).toBe(true);
|
||||
const compactedLines = (await fs.readFile(path.join(dir, "sess-main.jsonl"), "utf-8"))
|
||||
.split(/\r?\n/)
|
||||
.filter((l) => l.trim().length > 0);
|
||||
const compactedLines = collectNonEmptyLines(
|
||||
await fs.readFile(path.join(dir, "sess-main.jsonl"), "utf-8"),
|
||||
);
|
||||
expect(compactedLines).toHaveLength(3);
|
||||
const filesAfterCompact = await fs.readdir(dir);
|
||||
expect(filesAfterCompact).toContainEqual(expect.stringMatching(/^sess-main\.jsonl\.bak\./));
|
||||
|
||||
Reference in New Issue
Block a user