Q126: a file write and its record succeed or fail together
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
11cdc4af20
commit
5799a3561f
7 files changed
+119
-48
No files matched your search
@@ -66,4 +66,19 @@ describe("files shared in a private conversation", () => {
|
||||
rmSync(huge);
|
||||
connection.close();
|
||||
});
|
||||
|
||||
test("an import whose record fails leaves no stored copy behind", async () => {
|
||||
const connection = new DatabaseConnection(join(tmpdir(), `ac-import-fail-${randomUUID()}.db`));
|
||||
let orgId = "";
|
||||
connection.transaction(() => {
|
||||
orgId = new OrganizationService(connection.db).createOrganization({ organizationName: "Acme", employeeName: "Yang", mission: "m", goal: "g" });
|
||||
});
|
||||
const source = join(tmpdir(), `ac-import-fail-${randomUUID()}.md`);
|
||||
writeFileSync(source, "notes");
|
||||
connection.db.exec("create trigger registry_down before insert on file_objects begin select raise(abort, 'registry down'); end;");
|
||||
const artifacts = join(tmpdir(), `ac-import-fail-art-${randomUUID()}`);
|
||||
await expect(new FileService(connection.db, artifacts).importPath(orgId, source, null)).rejects.toThrow("registry down");
|
||||
expect(readdirSync(artifacts, { recursive: true }).filter((entry) => String(entry).endsWith(".md"))).toEqual([]);
|
||||
connection.close();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user