From 4fbfb27d1da1e18d09cf3b8c521d0b2ec771f3cc Mon Sep 17 00:00:00 2001 From: Nguyen Thanh Dat Date: Fri, 21 Aug 2026 13:28:03 +0700 Subject: [PATCH] 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. --- tests/management-client-config-route.test.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/management-client-config-route.test.ts b/tests/management-client-config-route.test.ts index 6db5a921af..baee2a34d2 100644 --- a/tests/management-client-config-route.test.ts +++ b/tests/management-client-config-route.test.ts @@ -1,4 +1,5 @@ import { describe, expect, test } from "bun:test"; +import { join } from "node:path"; import { handleManagementAPI } from "../src/server/management-api"; import { OPENCODE_API_KEY_ENV, @@ -332,12 +333,17 @@ describe("GET /api/client-config", () => { test("an accepted override still resolves through the route", async () => { const previous = process.env.PI_CODING_AGENT_DIR; - process.env.PI_CODING_AGENT_DIR = "/tmp/opencodex-pi-route-fixture"; + // One binding for the override, so the env value and the expectation cannot + // drift apart, and `join` for the separator: the resolver builds the + // destination with `join`, which is `\` on win32, so a hard-coded POSIX + // string asserted the platform rather than the override taking effect. + const overrideDir = "/tmp/opencodex-pi-route-fixture"; + process.env.PI_CODING_AGENT_DIR = overrideDir; try { const response = await clientConfigApi(baseConfig(), "?client=pi"); expect(response.status).toBe(200); const body = await response.json() as ClientConfigEnvelope; - expect(body.destination).toBe("/tmp/opencodex-pi-route-fixture/models.json"); + expect(body.destination).toBe(join(overrideDir, "models.json")); } finally { if (previous === undefined) delete process.env.PI_CODING_AGENT_DIR; else process.env.PI_CODING_AGENT_DIR = previous;