test(session): cover close drain failures
This commit is contained in:
@@ -97,6 +97,7 @@ describe("FileSessionStorage writer", () => {
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
vi.restoreAllMocks();
|
||||
await fsp.rm(tempDir, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
@@ -120,6 +121,17 @@ describe("FileSessionStorage writer", () => {
|
||||
|
||||
expect(fs.readFileSync(sessionPath, "utf8")).toBe("one\ntwo\n");
|
||||
});
|
||||
|
||||
it("rejects close when draining a queued append fails", async () => {
|
||||
const sessionPath = path.join(tempDir, "close-error.jsonl");
|
||||
const writer = storage.openWriter(sessionPath, { flags: "w" });
|
||||
void writer.append("one\n");
|
||||
vi.spyOn(fs, "writeSync").mockImplementation(() => {
|
||||
throw new Error("disk full");
|
||||
});
|
||||
|
||||
await expect(writer.close()).rejects.toThrow("disk full");
|
||||
});
|
||||
});
|
||||
|
||||
describe("FileSessionStorage.deleteSessionWithArtifacts", () => {
|
||||
|
||||
Reference in New Issue
Block a user