Skip to content

Commit ef41e8a

Browse files
committed
test: resolve macOS tmpdir symlink in worktree specs and price a current model
The PR worktree fixtures built expected paths from the unresolved /var tmpdir, while process.cwd() reports /private/var after chdir. models.dev no longer lists claude-3-opus, so the live pricing test now uses claude-opus-4-5.
1 parent 17ec32d commit ef41e8a

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

‎source/commands/gh-pr-worktree.spec.ts‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
import {execFileSync} from 'node:child_process';
2-
import {existsSync, mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync} from 'node:fs';
2+
import {
3+
existsSync,
4+
mkdtempSync,
5+
mkdirSync,
6+
readFileSync,
7+
realpathSync,
8+
rmSync,
9+
writeFileSync,
10+
} from 'node:fs';
311
import {tmpdir} from 'node:os';
412
import {basename, dirname, join} from 'node:path';
513
import test from 'ava';
@@ -17,7 +25,9 @@ type MockOptions = {
1725
};
1826

1927
function fixture(options: MockOptions = {}) {
20-
const root = mkdtempSync(join(tmpdir(), 'nanocoder-pr-test-'));
28+
// realpath: macOS tmpdir is under the /var -> /private/var symlink, and
29+
// process.cwd() reports the resolved path after chdir.
30+
const root = realpathSync(mkdtempSync(join(tmpdir(), 'nanocoder-pr-test-')));
2131
const worktree = join(dirname(root), `${basename(root)}-pr-42`);
2232
const gitCalls: string[][] = [];
2333
const ghCalls: string[][] = [];
@@ -253,7 +263,9 @@ test.serial('entering the worktree makes it the session cwd and project root', a
253263
});
254264

255265
function localGitFixture() {
256-
const fixtureRoot = mkdtempSync(join(tmpdir(), 'nanocoder pr git '));
266+
const fixtureRoot = realpathSync(
267+
mkdtempSync(join(tmpdir(), 'nanocoder pr git ')),
268+
);
257269
const repo = join(fixtureRoot, 'repo with spaces');
258270
const bare = join(fixtureRoot, 'pull refs.git');
259271
const worktree = join(fixtureRoot, 'repo with spaces-pr-42');

‎source/models/models-dev-client.spec.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,8 @@ test('getModelPricing - returns pricing for gpt-4o (models.dev)', async t => {
437437
t.true(pricing!.output >= 0);
438438
});
439439

440-
test('getModelPricing - returns pricing for claude-3-opus (models.dev)', async t => {
441-
const pricing = await getModelPricing('claude-3-opus');
440+
test('getModelPricing - returns pricing for claude-opus-4-5 (models.dev)', async t => {
441+
const pricing = await getModelPricing('claude-opus-4-5');
442442
t.truthy(pricing);
443443
t.true(typeof pricing!.input === 'number');
444444
t.true(typeof pricing!.output === 'number');

0 commit comments

Comments
 (0)