Skip to content

Commit 8c6fa81

Browse files
committed
test(service): assert the relative sqlite home is actually absolutized
The relative-path case only rejected the exact raw string, so it stayed green for any other non-absolute transform. Extract the emitted value per artifact format (launchd is XML, systemd is a quoted Environment= line) and assert absoluteness plus the expected terminal component.
1 parent 960013e commit 8c6fa81

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

‎tests/service.test.ts‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { afterEach, describe, expect, spyOn, test } from "bun:test";
22
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
33
import { tmpdir } from "node:os";
4-
import { join } from "node:path";
4+
import { isAbsolute, join, posix, win32 } from "node:path";
55
import * as serviceModule from "../src/service";
66
import { saveConfig } from "../src/config";
77
import { windowsEnvIndirectBatchValue } from "../src/lib/win-paths";
@@ -695,8 +695,24 @@ describe("launchd service plist", () => {
695695
process.env.CODEX_SQLITE_HOME = "relative-sqlite-home";
696696
const plist = buildPlist();
697697

698-
expect(plist).toContain("<key>CODEX_SQLITE_HOME</key>");
699-
expect(plist).not.toContain("<string>relative-sqlite-home</string>");
698+
// Assert the emitted value is actually absolute. Rejecting only the raw string would
699+
// stay green for any other non-absolute transform, which is the whole thing this test
700+
// exists to catch. The two artifact formats differ, so each is extracted on its own
701+
// terms: launchd is XML, systemd is a quoted Environment= line.
702+
const plistValue = /<key>CODEX_SQLITE_HOME<\/key>\s*<string>([^<]*)<\/string>/.exec(plist)?.[1];
703+
expect(plistValue).toBeDefined();
704+
expect(
705+
isAbsolute(plistValue!) || posix.isAbsolute(plistValue!) || win32.isAbsolute(plistValue!),
706+
).toBe(true);
707+
expect(plistValue!.endsWith("relative-sqlite-home")).toBe(true);
708+
709+
const unit = buildUnit();
710+
const unitValue = /Environment="CODEX_SQLITE_HOME=([^"]*)"/.exec(unit)?.[1];
711+
expect(unitValue).toBeDefined();
712+
expect(
713+
isAbsolute(unitValue!) || posix.isAbsolute(unitValue!) || win32.isAbsolute(unitValue!),
714+
).toBe(true);
715+
expect(unitValue!.endsWith("relative-sqlite-home")).toBe(true);
700716
} finally {
701717
if (inherited === undefined) delete process.env.CODEX_SQLITE_HOME;
702718
else process.env.CODEX_SQLITE_HOME = inherited;

0 commit comments

Comments
 (0)