- MCP
- code on this site's /mcp
- CLI
- none: the JSON below is the answer
- JSON
- /christopher/abso-core/files/server/test/push-snapshot.test.ts?format=json
67 linescodex-capacity-chair 100%Last change codex-capacity-chair in version 177, 1 version changed it
codex-capacity-chair has unpushed changes at lines 68–126no start notelast edit
1import assert from "node:assert/strict";
2import { test } from "node:test";
3import { answer } from "../../worker/project/http.ts";
4import { MemoryStore, Project } from "../../worker/project/project.ts";
5import { DiskFirstRuntime } from "../src/disk-first-runtime.ts";
6import { SqliteLog } from "../src/engine-project.ts";
7import { pushSnapshot } from "../src/push-snapshot.ts";
8import { memoryStorage } from "./helpers.ts";
10test("push snapshot reads a pinned version through fresh disk scopes after another publish", (t) => {
11 const storage = memoryStorage();
12 t.after(() => storage.db.close());
13 const seed = new MemoryStore();
14 new Project(seed).init({ "a.txt": "old\n", "b.txt": "stable\n" }, 0);
15 new SqliteLog(storage).append(seed.entries);
16 t.mock.method(Project, "load", () => {
17 throw Error("full-history replay forbidden");
18 });
19 const runtime = () => new DiskFirstRuntime(storage, "push-snapshot", "push-snapshot");
20 while (!runtime().preparePage(() => {}).ready) {}
21 let reads = 0;
22 const snapshot = pushSnapshot(
23 runtime().read(
24 (calls) => calls.sharedPushMetadata(),
25 () => {},
26 ),
27 (version, path) => {
28 reads++;
29 return runtime().read(
30 (current) => current.fileTextAt(version, path),
31 () => {},
32 );
33 },
34 (version, paths) => {
35 reads++;
36 return runtime().read(
37 (current) => current.fileTextsAt(version, paths),
38 () => {},
39 );
40 },
41 );
42 assert.equal(reads, 0);
43 assert.equal(snapshot.files["a.txt"], "old\n");
44 for (const [op, body] of [
45 ["sync", {}],
46 ["record", { files: { "a.txt": "new", "b.txt": "changed" } }],
47 ["publish", { message: "Changed during push" }],
48 ] as const)
49 assert.equal(
50 runtime().write(
51 (calls) => answer(calls, op, "alice", body),
52 () => {},
53 ).status,
54 200,
55 );
56 assert.equal(snapshot.files["b.txt"], "stable\n");
57 assert.equal(snapshot.files["a.txt"], "old\n");
58 assert.equal(snapshot.version, 0);
59 assert.equal(reads, 2);
60 assert.equal(
61 runtime().read(
62 (calls) => calls.shared().version,
63 () => {},
64 ),
65 1,
66 );
67});