Versions 87 to 318
new file, 35 lines
1+import assert from "node:assert/strict"; 2+import { test } from "node:test"; 3+import { answer } from "../../worker/project/http.ts"; 4+import { DiskFirstRuntime } from "../src/disk-first-runtime.ts"; 5+import { memoryStorage } from "./helpers.ts"; 7+test("disk runtime moves a text file without using a stale reader", (t) => { 8+ const storage = memoryStorage(); 9+ t.after(() => storage.db.close()); 10+ const runtime = () => new DiskFirstRuntime(storage, "move", "move"); 11+ runtime().initialize( 12+ (c) => answer(c, "init", undefined, { files: { "a.txt": "one\ntwo\n" } }), 15+ while (!runtime().preparePage(() => {}).ready) {} 16+ const result = runtime().write( 17+ (c) => answer(c, "move", "alice", { from: "a.txt", to: "b.txt" }), 20+ assert.equal(result.status, 200, JSON.stringify(result)); 23+ (c) => answer(c, "publish", "alice", { message: "move" }), 30+ (c) => c.shared().files, 33+ { "b.txt": "one\ntwo\n" },