Skip to content

Commit 8575838

Browse files
committed
test(clients): assert the Pi override with join, not a POSIX separator
`an accepted override still resolves through the route` hard-coded "/tmp/opencodex-pi-route-fixture/models.json". The resolver builds that destination with `join`, which is `\` on win32, so the case asserted the host's path separator rather than the override taking effect and was red on every Windows run: Expected: "/tmp/opencodex-pi-route-fixture/models.json" Received: "\tmp\opencodex-pi-route-fixture\models.json" Build the expectation with `join` from one binding shared with the env value. `join` is identity for this input on POSIX, so Linux and macOS are unchanged. The assertion still pins what it was written for: making `piAgentDir` ignore the override fails this case, so it did not become a tautology. Refs #2152.
1 parent 3c6a452 commit 8575838

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎tests/management-client-config-route.test.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { describe, expect, test } from "bun:test";
2+
import { join } from "node:path";
23
import { handleManagementAPI } from "../src/server/management-api";
34
import {
45
OPENCODE_API_KEY_ENV,
@@ -314,12 +315,17 @@ describe("GET /api/client-config", () => {
314315

315316
test("an accepted override still resolves through the route", async () => {
316317
const previous = process.env.PI_CODING_AGENT_DIR;
317-
process.env.PI_CODING_AGENT_DIR = "/tmp/opencodex-pi-route-fixture";
318+
// One binding for the override, so the env value and the expectation cannot
319+
// drift apart, and `join` for the separator: the resolver builds the
320+
// destination with `join`, which is `\` on win32, so a hard-coded POSIX
321+
// string asserted the platform rather than the override taking effect.
322+
const overrideDir = "/tmp/opencodex-pi-route-fixture";
323+
process.env.PI_CODING_AGENT_DIR = overrideDir;
318324
try {
319325
const response = await clientConfigApi(baseConfig(), "?client=pi");
320326
expect(response.status).toBe(200);
321327
const body = await response.json() as ClientConfigEnvelope;
322-
expect(body.destination).toBe("/tmp/opencodex-pi-route-fixture/models.json");
328+
expect(body.destination).toBe(join(overrideDir, "models.json"));
323329
} finally {
324330
if (previous === undefined) delete process.env.PI_CODING_AGENT_DIR;
325331
else process.env.PI_CODING_AGENT_DIR = previous;

0 commit comments

Comments
 (0)