import { describe, it, expect, beforeEach, afterEach } from 'vitest'; import { mkdtempSync, rmSync } from 'fs'; import { tmpdir } from 'os'; import { join } from 'path'; import { addMemory, searchMemory, listMemory } from '../src/core/services/memoryService.js'; describe('memoryService', () => { let cwd: string; beforeEach(() => { cwd = mkdtempSync(join(tmpdir(), 'ah-mem-')); }); afterEach(() => { rmSync(cwd, { recursive: true, force: true }); }); it('creates and searches memory', () => { const m = addMemory(cwd, { title: 'DNS cache', category: 'technical', content: 'Use TTL' }); expect(m.id.startsWith('MEM-')).toBe(true); expect(searchMemory(cwd, 'TTL')).toHaveLength(1); expect(listMemory(cwd)).toHaveLength(1); }); });