fix: bootstrap registry on first workspace list
This commit is contained in:
@@ -155,6 +155,12 @@ export class WorkspaceRegistry {
|
||||
}
|
||||
|
||||
async list(): Promise<WorkspaceRevision[]> {
|
||||
const active = await this.tryActiveState();
|
||||
if (active) return active.revisions;
|
||||
// A clean installation has no active snapshot until the first registry operation. Keep
|
||||
// this lazy so health/startup remain available when Git is temporarily unreachable, while
|
||||
// still refusing corrupted existing state (tryActiveState throws instead of returning none).
|
||||
await this.bootstrap();
|
||||
return (await this.activeState()).revisions;
|
||||
}
|
||||
|
||||
|
||||
@@ -254,6 +254,21 @@ test("bootstraps a checkout and activates a validated immutable snapshot", async
|
||||
});
|
||||
});
|
||||
|
||||
test("first list lazily bootstraps a clean registry", async () => {
|
||||
const remote = await fixture();
|
||||
const root = join(remote.root, "registry");
|
||||
const registry = new WorkspaceRegistry(config(root, remote.remote));
|
||||
|
||||
await expect(registry.list()).resolves.toEqual([
|
||||
expect.objectContaining({
|
||||
id: "psd-clinical",
|
||||
commit: remote.initialCommit,
|
||||
state: "operational",
|
||||
}),
|
||||
]);
|
||||
expect(existsSync(join(root, "state", "active.json"))).toBe(true);
|
||||
});
|
||||
|
||||
test("publishes create, update, and delete with the configured Git author identity", async () => {
|
||||
const remote = await fixture();
|
||||
const registry = new WorkspaceRegistry(config(join(remote.root, "registry"), remote.remote, {
|
||||
|
||||
Reference in New Issue
Block a user