test: cover concurrent registry and close cleanup
This commit is contained in:
@@ -189,6 +189,25 @@ test("Pi receives the leased workspace runtime config and releases it on direct
|
||||
expect(release).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
test("a close-only child event releases its temporary Pi agent snapshot", () => {
|
||||
const child = recordingChild();
|
||||
let snapshotDir: string | undefined;
|
||||
const mgr = new PiProcessManager(loadConfig({}), {
|
||||
spawnFn: (_command, _args, options) => {
|
||||
snapshotDir = options.env.PI_CODING_AGENT_DIR;
|
||||
return child as any;
|
||||
},
|
||||
});
|
||||
|
||||
mgr.createFor("close-only-snapshot", {});
|
||||
expect(snapshotDir).toBeTruthy();
|
||||
expect(existsSync(snapshotDir!)).toBe(true);
|
||||
|
||||
child.emit("close", 0);
|
||||
expect(existsSync(snapshotDir!)).toBe(false);
|
||||
mgr.teardown("close-only-snapshot");
|
||||
});
|
||||
|
||||
test.each([
|
||||
["new", "auth.json", '{"deepseek":{"key":"!runtime-auth-command runtime-secret /private/runtime-auth"}}\n'],
|
||||
["new", "models.json", '{"providers":{"local-qwen":{"headers":["!runtime-model-command runtime-secret /private/runtime-model"]}}}\n'],
|
||||
|
||||
@@ -254,18 +254,21 @@ test("bootstraps a checkout and activates a validated immutable snapshot", async
|
||||
});
|
||||
});
|
||||
|
||||
test("first list lazily bootstraps a clean registry", async () => {
|
||||
test("concurrent first lists lazily bootstrap a clean registry once safely", 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([
|
||||
const [first, second] = await Promise.all([registry.list(), registry.list()]);
|
||||
for (const revisions of [first, second]) {
|
||||
expect(revisions).toEqual([
|
||||
expect.objectContaining({
|
||||
id: "psd-clinical",
|
||||
commit: remote.initialCommit,
|
||||
state: "operational",
|
||||
}),
|
||||
]);
|
||||
}
|
||||
expect(existsSync(join(root, "state", "active.json"))).toBe(true);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user