fix: fallback to in-memory state when convex functions are unavailable

This commit is contained in:
Codex
2026-02-18 14:24:36 +00:00
parent 53a0e3576e
commit 42684125f9
5 changed files with 134 additions and 4 deletions

View File

@@ -5,7 +5,7 @@ const assert = require("node:assert/strict");
const os = require("node:os");
const path = require("node:path");
const fs = require("node:fs/promises");
const { JsonFileStateStore } = require("../src/lib/state-store");
const { JsonFileStateStore, InMemoryStateStore } = require("../src/lib/state-store");
test("load returns null when state file does not exist", async () => {
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "xartaudio-state-test-"));
@@ -33,3 +33,12 @@ test("save and load roundtrip state", async () => {
assert.deepEqual(actual, expected);
});
test("in memory state store roundtrips without filesystem", async () => {
const store = new InMemoryStateStore();
assert.equal(await store.load(), null);
await store.save({ engine: { jobs: {} } });
const loaded = await store.load();
assert.deepEqual(loaded, { engine: { jobs: {} } });
});