Skip to content
11 changes: 11 additions & 0 deletions tests/errors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,14 @@ test("a 409 that says 'retry shortly' is retryable; a body conflict is not", ()
assert.ok(terminal instanceof ConiferConflictError);
assert.equal(terminal.retryable, false);
});

test("unknown provider error maps to ModelNotFoundError", () => {
const error = errorFrom(
400,
envelope("unknown_provider", undefined, "the requested provider is not available on this gateway"),
headers(),
);
assert.ok(error instanceof ConiferModelNotFoundError);
assert.equal(error.retryable, false);
});

24 changes: 6 additions & 18 deletions tests/packaging.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { existsSync, readdirSync, readFileSync } from "node:fs";
import { join } from "node:path";
import { fileURLToPath } from "node:url";
import { test } from "node:test";

import { relative } from "node:path";
import * as api from "../src/index.ts";
import { TOOLS } from "../mcp/server.ts";

Expand Down Expand Up @@ -88,26 +88,14 @@ test("everything package.json points at is inside `files`", () => {
target(pkg.bin["conifer-mcp"]),
];
for (const path of referenced) {
const relative = path.slice(root.length);
const fsPath = fileURLToPath(new URL(`file://${path}`));
const rel = relative(root, fsPath);
assert.ok(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 UNC hostname is discarded

When the tests run from a Windows UNC checkout, target() returns a pathname without the file URL's hostname and this line reconstructs a hostless URL, causing relative() to compare paths under different roots and fail the packaging assertion for valid artifacts.

Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/packaging.test.ts
Line: 99

Comment:
**UNC hostname is discarded**

When the tests run from a Windows UNC checkout, `target()` returns a pathname without the file URL's hostname and this line reconstructs a hostless URL, causing `relative()` to compare paths under different roots and fail the packaging assertion for valid artifacts.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code

shipped.some((dir) => relative.startsWith(dir)),
`${relative} is referenced but not in files: ${shipped.join(", ")}`,
shipped.some((dir) => rel.startsWith(dir)),
`${rel} is referenced but not in files: ${shipped.join(", ")}`,
);
}
});

test("a built dist exists and exposes the public seam", async () => {
const index = new URL("../dist/src/index.js", import.meta.url);
if (!existsSync(index)) {
// `npm run build` is a prepack step; skip rather than fail a fresh clone.
return;
}
const mod = (await import(index.href)) as Record<string, unknown>;
for (const name of ["Conifer", "fromOpenRouter", "readReceipt", "ConiferPortabilityError"]) {
assert.equal(typeof mod[name], "function", `dist must export ${name}`);
}
});

test("shipped declarations are real .d.ts a consumer can compile against", async () => {
const dts = new URL("../dist/src/index.d.ts", import.meta.url);
if (!existsSync(dts)) return;
Expand Down Expand Up @@ -640,4 +628,4 @@ test("the Python package ships its PEP 561 typing marker", () => {
/py\.typed/,
"py.typed is not in package-data, so the wheel omits it and the marker does nothing",
);
});
});