feat(backend): support container runtime paths

This commit is contained in:
2026-07-11 21:32:33 +02:00
parent a0daa319ca
commit c6c00c336a
9 changed files with 144 additions and 38 deletions
+30
View File
@@ -51,3 +51,33 @@ test("createPiModelLister caches within ttl (spawns once for two calls)", async
rmSync(path.dirname(script), { recursive: true, force: true });
}
});
test("production model-list spawn preserves PATH and passes the portable data root", async () => {
const script = scriptWith([]);
const calls: any[][] = [];
const previousPath = process.env.PATH;
process.env.PATH = "/usr/local/bin:/usr/bin";
try {
const lister = createPiModelLister(loadConfig({
THT_HARNESS_DIR: "/app/harness",
PI_BIN: "/usr/local/bin/pi",
THT_DATA_ROOT: "/data",
}), {
spawnFn: (...args: any[]) => {
calls.push(args);
return spawn("node", [FAKE, script]) as any;
},
});
await lister();
expect(calls[0][0]).toBe("/usr/local/bin/pi");
expect(calls[0][1]).toEqual(["--mode", "rpc"]);
expect(calls[0][2]).toMatchObject({
cwd: "/app/harness",
env: expect.objectContaining({ PATH: "/usr/local/bin:/usr/bin", THT_DATA_ROOT: "/data" }),
});
} finally {
if (previousPath === undefined) delete process.env.PATH;
else process.env.PATH = previousPath;
rmSync(path.dirname(script), { recursive: true, force: true });
}
});