- MCP
- code on this site's /mcp
- CLI
- none: the JSON below is the answer
- JSON
- /christopher/abso-core/files/server/test/definition-scratch-runtime.test.ts?format=json
55 linescodex-capacity-chair 100%Last change codex-capacity-chair in version 175, 1 version changed it
1import assert from "node:assert/strict";
2import { test } from "node:test";
3import { answer } from "../../worker/project/http.ts";
4import { Project } from "../../worker/project/project.ts";
5import { DiskFirstRuntime } from "../src/disk-first-runtime.ts";
6import { memoryStorage } from "./helpers.ts";
8test("scratch-backed definition scanning preserves code-file record and publish", (t) => {
9 const storage = memoryStorage();
10 t.after(() => storage.db.close());
11 const runtime = () => new DiskFirstRuntime(storage, "text-bound", "text-bound");
12 const unchanged = "stable".repeat(10000);
13 const old = `${"old".repeat(20000)}\n${unchanged}\n`;
14 const current = `changed\n${unchanged}\n`;
15 assert.equal(
16 runtime().initialize(
17 (c) => answer(c, "init", undefined, { files: { f: old } }),
18 () => {},
19 ).status,
20 200,
21 );
22 while (!runtime().preparePage(() => {}).ready) {}
23 t.mock.method(Project, "load", () => {
24 throw Error("full history replay forbidden");
25 });
27 assert.equal(
28 runtime().write(
29 (c) => answer(c, "record", "writer", { files: { f: current } }),
30 () => {},
31 ).status,
32 200,
33 );
34 assert.equal(
35 runtime().write(
36 (c) => answer(c, "publish", "writer", { message: "replace" }),
37 () => {},
38 ).status,
39 200,
40 );
41 assert.equal(
42 runtime().read(
43 (c) => c.filesAt(0)["f"],
44 () => {},
45 ),
46 old,
47 );
48 assert.equal(
49 runtime().read(
50 (c) => c.shared().files["f"],
51 () => {},
52 ),
53 current,
54 );
55});