- MCP
- code on this site's /mcp
- CLI
- none: the JSON below is the answer
- JSON
- /christopher/abso-core/files/src/engine/test/graph-insertion-runs.test.ts?format=json
24 linescodex-capacity-chair 100%Last change codex-capacity-chair in version 162, 1 version changed it
1import assert from "node:assert/strict";
2import { test } from "node:test";
3import { buildBase, Graph } from "../index.ts";
4import { SqlState } from "./storage-helper.ts";
6test("many insertion runs reopen without fetching every run", (t) => {
7 const storage = new SqlState();
8 t.after(() => storage.db.close());
9 const files = Object.fromEntries(Array.from({ length: 257 }, (_, i) => [`file-${i}.txt`, `value ${i}`]));
10 const atom = buildBase(files, { author: "fixture", message: "many files", time: 0 });
11 new Graph({ storage }).add(atom);
12 assert.ok(JSON.stringify(storage.read("atoms", "0")).length < 2048);
13 const read = storage.read.bind(storage);
14 let runs = 0;
15 storage.read = (collection, key) => {
16 if (collection === "atom-inserts:0") runs++;
17 return read(collection, key);
18 };
19 const saved = new Graph({ storage }).atom("a0");
20 assert.equal(saved.inserts.length, atom.inserts.length);
21 assert.equal(runs, 0);
22 assert.deepEqual([...saved.inserts[256]!.lines], atom.inserts[256]!.lines);
23 assert.equal(runs, 1);
24});