源码快照 @ 2026-09-02 (source-only, 剔除非源码素材)
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdtemp, rm, stat } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import test from "node:test";
|
||||
import { WorldStateStore } from "../src/store.ts";
|
||||
|
||||
test("local world state is owner-only and addressable by world name", async () => {
|
||||
const root = await mkdtemp(join(tmpdir(), "openwork-world-store-"));
|
||||
try {
|
||||
const store = new WorldStateStore(join(root, "worlds"));
|
||||
const path = await store.save("demo", '{"name":"demo"}');
|
||||
assert.equal((await stat(path)).mode & 0o777, 0o600);
|
||||
assert.equal(await store.read("demo"), '{"name":"demo"}\n');
|
||||
assert.deepEqual(await store.list(), [path]);
|
||||
assert.equal(await store.forget("demo"), true);
|
||||
assert.equal(await store.forget("demo"), false);
|
||||
} finally {
|
||||
await rm(root, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user