update
This commit is contained in:
1 parent
66158e222e
commit
67c757f481
314 files changed
+37945
-22962
No files matched your search
@@ -0,0 +1,59 @@
|
||||
import { mkdtemp, rm } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { tmpdir } from "node:os";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { AppDatabase } from "../../src/main/database";
|
||||
|
||||
const tempDirs: string[] = [];
|
||||
|
||||
async function createTempDir(prefix: string) {
|
||||
const dir = await mkdtemp(join(tmpdir(), prefix));
|
||||
tempDirs.push(dir);
|
||||
return dir;
|
||||
}
|
||||
|
||||
afterEach(async () => {
|
||||
await Promise.all(tempDirs.splice(0).map((dir) => rm(dir, { recursive: true, force: true })));
|
||||
});
|
||||
|
||||
describe("knowledge provenance", () => {
|
||||
it("preserves or refreshes sourceRunId when an existing knowledge entry is updated", async () => {
|
||||
const profileDir = await createTempDir("agentcompany-knowledge-provenance-");
|
||||
const db = new AppDatabase(profileDir);
|
||||
db.init();
|
||||
|
||||
const companyId = db.saveCompany({
|
||||
name: "Knowledge Provenance Co",
|
||||
description: "Tests sourceRunId updates on knowledge entry edits",
|
||||
status: "active",
|
||||
});
|
||||
|
||||
const knowledgeId = db.saveKnowledgeEntry({
|
||||
companyId,
|
||||
category: "lesson_learned",
|
||||
topic: "Original lesson",
|
||||
content: "Initial content",
|
||||
importance: "medium",
|
||||
sourceRunId: null,
|
||||
});
|
||||
|
||||
db.saveKnowledgeEntry({
|
||||
id: knowledgeId,
|
||||
companyId,
|
||||
category: "lesson_learned",
|
||||
topic: "Original lesson",
|
||||
content: "Updated content with better guidance",
|
||||
importance: "high",
|
||||
sourceRunId: "run-123",
|
||||
});
|
||||
|
||||
const entry = db.queryAll<{ sourceRunId: string | null; importance: string }>(
|
||||
"select source_run_id as sourceRunId, importance from knowledge_base where id = ? limit 1",
|
||||
knowledgeId,
|
||||
)[0];
|
||||
expect(entry?.sourceRunId).toBe("run-123");
|
||||
expect(entry?.importance).toBe("high");
|
||||
|
||||
db.close();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user