- MCP
- code on this site's /mcp
- CLI
- none: the JSON below is the answer
- JSON
- /christopher/abso-core/files/server/test/push-snapshot-batch.test.ts?format=json
34 linescodex-capacity-chair 100%Last change codex-capacity-chair in version 177, 1 version changed it
1import assert from "node:assert/strict";
2import { test } from "node:test";
3import { answer } from "../../worker/project/http.ts";
4import { EngineProject } from "../src/engine-project.ts";
5import { pushSnapshot } from "../src/push-snapshot.ts";
6import { memoryStorage } from "./helpers.ts";
8test("push batches cap file count and text while preserving exact lazy contents", (t) => {
9 const storage = memoryStorage();
10 t.after(() => storage.db.close());
11 const project = EngineProject.open(storage);
12 const files = Object.fromEntries(Array.from({ length: 130 }, (_, i) => [`f${i}`, `${i}\n`]));
13 assert.equal(answer(project, "init", undefined, { files }).status, 200);
14 let batches = 0;
15 const snapshot = pushSnapshot(
16 project.sharedPushMetadata(),
17 () => {
18 throw Error("single read forbidden");
19 },
20 (version, paths) => {
21 batches++;
22 return project.fileTextsAt(version, paths);
23 },
24 );
25 assert.equal(batches, 0);
26 assert.deepEqual({ ...snapshot.files }, files);
27 assert.equal(batches, 3);
28 const large = "x".repeat(70000) + "\n";
29 assert.equal(answer(project, "record", "writer", { files: { large } }).status, 200);
30 assert.equal(answer(project, "publish", "writer", { message: "Large file" }).status, 200);
31 const batch = project.fileTextsAt(1, ["large", "f0"]);
32 assert.deepEqual(Object.keys(batch), ["large"]);
33 assert.equal(batch.large, large);
34});