feat(FN-2112): merge fusion/fn-2112
This commit is contained in:
@@ -141,10 +141,24 @@ describe("memory-backend", () => {
|
|||||||
expect(result.exists).toBe(false);
|
expect(result.exists).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Note: Testing read failure is complex in ESM because we can't easily mock
|
it("should throw MemoryBackendError on read failure", async () => {
|
||||||
// the fs/promises module. The error handling is tested through integration tests
|
// Make the long-term memory path a directory so readFile throws EISDIR (not ENOENT)
|
||||||
// and the MemoryBackendError class tests above.
|
const longTermDir = join(tempDir, ".fusion", "memory", "MEMORY.md");
|
||||||
it.todo("should throw MemoryBackendError on read failure");
|
await mkdir(longTermDir, { recursive: true });
|
||||||
|
|
||||||
|
const backend = new FileMemoryBackend();
|
||||||
|
|
||||||
|
await expect(backend.read(tempDir)).rejects.toThrow(MemoryBackendError);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await backend.read(tempDir);
|
||||||
|
} catch (err) {
|
||||||
|
expect(err).toBeInstanceOf(MemoryBackendError);
|
||||||
|
expect((err as MemoryBackendError).code).toBe("READ_FAILED");
|
||||||
|
expect((err as MemoryBackendError).backend).toBe("file");
|
||||||
|
expect((err as MemoryBackendError).message).toContain("Failed to read memory file");
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("write", () => {
|
describe("write", () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user