mirror of
https://github.com/Elysola/WebHooker.git
synced 2026-11-21 01:23:40 +00:00
fix(storage): repair orphaned KV routes
Repair orphaned KV routes before serving KV-only configuration.
This commit is contained in:
2 files changed
+32
-1
No files matched your search
@@ -380,6 +380,22 @@ describe("kvConfigStore", () => {
|
||||
expect(JSON.parse(store.get("config:routes")!)).toEqual([]);
|
||||
});
|
||||
|
||||
it("repairs orphaned routes before a reused group id can inherit them", async () => {
|
||||
const { kv, store } = createMemoryKV();
|
||||
store.set("config:groups", JSON.stringify([group("current")]));
|
||||
store.set(
|
||||
"config:routes",
|
||||
JSON.stringify([route("orphan", "reused"), route("live", "current")]),
|
||||
);
|
||||
const cfg = kvConfigStore(kv);
|
||||
|
||||
expect((await cfg.loadRoutes()).map((r) => r.id)).toEqual(["live"]);
|
||||
expect(JSON.parse(store.get("config:routes")!)).toEqual([route("live", "current")]);
|
||||
|
||||
await expect(cfg.createGroup(group("reused"))).resolves.toBe(true);
|
||||
expect((await cfg.loadRoutes()).map((r) => r.id)).toEqual(["live"]);
|
||||
});
|
||||
|
||||
it("backfills the same instance whichever cold start wins the race", async () => {
|
||||
const { kv, store } = createMemoryKV();
|
||||
store.set("config:groups", JSON.stringify([group("legacy")]));
|
||||
|
||||
Reference in new issue
Block a user