From c99ad377c663a2b623e02abec63ce5ae37f33bdd Mon Sep 17 00:00:00 2001 From: catlog22 Date: Sun, 28 Dec 2025 23:01:40 +0800 Subject: [PATCH] test(memory-command): add unit tests for memory module Solution-ID: SOL-1735386000001 Issue-ID: ISS-1766921318981-15 Task-ID: T2 --- ccw/tests/memory-command.test.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/ccw/tests/memory-command.test.ts b/ccw/tests/memory-command.test.ts index 18341105..909a86ae 100644 --- a/ccw/tests/memory-command.test.ts +++ b/ccw/tests/memory-command.test.ts @@ -220,6 +220,27 @@ describe('memory command module', async () => { assert.ok(logs.some((l) => l.includes('Nothing to prune') || l.includes('No memory database found'))); }); + it('prune validates age format', async () => { + stubHttpRequest(); + + const errors: string[] = []; + mock.method(console, 'log', () => {}); + mock.method(console, 'error', (...args: any[]) => { + errors.push(args.map(String).join(' ')); + }); + + mock.method(process as any, 'exit', (code?: number) => { + throw new ExitError(code); + }); + + await assert.rejects( + memoryModule.memoryCommand('prune', [], { olderThan: 'not-an-age', dryRun: true }), + (err: any) => err instanceof ExitError && err.code === 1, + ); + + assert.ok(errors.some((e) => e.includes('Invalid age format'))); + }); + it('embed/embed-status/semantic-search fail fast without core-memory database', async () => { stubHttpRequest(); @@ -258,4 +279,3 @@ describe('memory command module', async () => { ); }); }); -