From 53083223793299a444f708f0d2f54b7c8cf76ad3 Mon Sep 17 00:00:00 2001 From: Wibias <37517432+Wibias@users.noreply.github.com> Date: Sun, 9 Aug 2026 03:56:18 +0200 Subject: [PATCH] test(omp): isolate path contract temp homes --- tests/omp-path-contract.test.ts | 40 +++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/omp-path-contract.test.ts diff --git a/tests/omp-path-contract.test.ts b/tests/omp-path-contract.test.ts new file mode 100644 index 000000000..cc0e04fc5 --- /dev/null +++ b/tests/omp-path-contract.test.ts @@ -0,0 +1,40 @@ +import { describe, expect, test } from "bun:test"; +import { mkdtempSync, rmSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import { ompModelsConfigPath } from "../src/clients/config-export"; + +function withTempHome(run: (home: string) => void): void { + const home = mkdtempSync(join(tmpdir(), "opencodex-omp-home-")); + try { + run(home); + } finally { + rmSync(home, { recursive: true, force: true }); + } +} + +describe("OMP path contract regressions", () => { + test("PI_CONFIG_DIR remains home-relative for slash- and tilde-prefixed values", () => { + withTempHome(home => { + for (const value of ["/custom-omp", "~/.custom-omp"]) { + expect(ompModelsConfigPath({ PI_CONFIG_DIR: value } as NodeJS.ProcessEnv, home)).toBe( + join(home, value, "agent", "models.yml"), + ); + } + }); + }); + + test("a named profile ignores PI_CODING_AGENT_DIR", () => { + withTempHome(home => { + const configDir = "custom-omp"; + + expect(ompModelsConfigPath({ + OMP_PROFILE: "work", + PI_CONFIG_DIR: configDir, + PI_CODING_AGENT_DIR: join(home, "wrong-agent"), + } as NodeJS.ProcessEnv, home)).toBe( + join(home, configDir, "profiles", "work", "agent", "models.yml"), + ); + }); + }); +});