fix: fallback to in-memory state when convex functions are unavailable
This commit is contained in:
@@ -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: {} } });
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user