test: consolidate failure guards and trim unused fixture APIs
This commit is contained in:
@@ -58,7 +58,6 @@ describe("additional client configuration dialects", () => {
|
||||
const client = getClients(home).find(
|
||||
(candidate) => candidate.name === name,
|
||||
);
|
||||
expect(client).toBeDefined();
|
||||
if (client === undefined) throw new Error(`missing ${name} client`);
|
||||
|
||||
await mkdir(client.markerPath ?? home, { recursive: true });
|
||||
@@ -126,7 +125,6 @@ describe("additional client configuration dialects", () => {
|
||||
it("preserves OpenCode JSONC comments and sibling registrations during update and removal", async () => {
|
||||
const home = await createTestTempDirectory("rea-opencode-jsonc-");
|
||||
const client = getClients(home).find(({ name }) => name === "opencode");
|
||||
expect(client).toBeDefined();
|
||||
if (client === undefined) throw new Error("missing OpenCode client");
|
||||
await mkdir(client.markerPath ?? home, { recursive: true });
|
||||
const original = `{
|
||||
@@ -177,7 +175,6 @@ describe("additional client configuration dialects", () => {
|
||||
it("rejects malformed OpenCode JSONC without creating a backup or changing bytes", async () => {
|
||||
const home = await createTestTempDirectory("rea-opencode-invalid-");
|
||||
const client = getClients(home).find(({ name }) => name === "opencode");
|
||||
expect(client).toBeDefined();
|
||||
if (client === undefined) throw new Error("missing OpenCode client");
|
||||
await mkdir(client.markerPath ?? home, { recursive: true });
|
||||
const invalid = '{ "mcp": { /* broken */ "rea": [ }';
|
||||
|
||||
@@ -506,8 +506,7 @@ describe("JavaScript runtime reconciliation local paths", () => {
|
||||
],
|
||||
});
|
||||
|
||||
expect(reconciled.ok).toBe(true);
|
||||
if (!reconciled.ok) return;
|
||||
if (!reconciled.ok) throw reconciled.error;
|
||||
const result = javascriptRuntimeReconciliationResultSchema.parse(
|
||||
reconciled.value.normalized_result,
|
||||
);
|
||||
|
||||
@@ -56,8 +56,7 @@ it("distinguishes computed require member values from literal members in source
|
||||
caller: "reference-require-members-test",
|
||||
policy: { secretPatterns: [] },
|
||||
});
|
||||
expect(result.ok).toBe(true);
|
||||
if (!result.ok) return;
|
||||
if (!result.ok) throw result.error;
|
||||
const graph = result.value;
|
||||
expect(graph.parse_failures).toEqual([]);
|
||||
expect(graph.relationships).toEqual([
|
||||
|
||||
@@ -29,8 +29,7 @@ it("imports Dockerfile-prefixed TypeScript with ordinary source evidence and unc
|
||||
caller: "dockerfile-language-test",
|
||||
policy: { secretPatterns: [] },
|
||||
});
|
||||
expect(result.ok).toBe(true);
|
||||
if (!result.ok) return;
|
||||
if (!result.ok) throw result.error;
|
||||
const graph = result.value;
|
||||
expect(graph.parse_failures).toEqual([]);
|
||||
expect(graph.relationships).toHaveLength(sourcePaths.length * 3);
|
||||
@@ -88,8 +87,7 @@ it("retains parser failures and hashes for malformed Dockerfile-prefixed TypeScr
|
||||
caller: "dockerfile-language-test",
|
||||
policy: { secretPatterns: [] },
|
||||
});
|
||||
expect(result.ok).toBe(true);
|
||||
if (!result.ok) return;
|
||||
if (!result.ok) throw result.error;
|
||||
expect(result.value.relationships).toEqual([]);
|
||||
expect(result.value.parse_failures).toEqual(
|
||||
paths.map((path) => ({
|
||||
|
||||
@@ -30,8 +30,7 @@ it("resolves dynamic source imports while retaining computed targets as unknown"
|
||||
caller: "reference-dynamic-import-test",
|
||||
policy: { secretPatterns: [] },
|
||||
});
|
||||
expect(result.ok).toBe(true);
|
||||
if (!result.ok) return;
|
||||
if (!result.ok) throw result.error;
|
||||
expect(result.value.parse_failures).toEqual([]);
|
||||
expect(result.value.relationships).toHaveLength(5);
|
||||
for (const [to, kind] of [
|
||||
|
||||
@@ -123,8 +123,7 @@ describe("reference source symlink import", () => {
|
||||
|
||||
const imported = await importTree(root);
|
||||
|
||||
expect(imported.ok).toBe(true);
|
||||
if (!imported.ok) return;
|
||||
if (!imported.ok) throw imported.error;
|
||||
expect(imported.value.entries).toContainEqual(
|
||||
expect.objectContaining({
|
||||
kind: "symlink",
|
||||
@@ -154,8 +153,7 @@ describe("reference source manifest inventory", () => {
|
||||
]);
|
||||
|
||||
const result = await importTree(root);
|
||||
expect(result.ok).toBe(true);
|
||||
if (!result.ok) return;
|
||||
if (!result.ok) throw result.error;
|
||||
expect(result.value.manifests).toEqual([
|
||||
"CMakeLists.txt",
|
||||
"src/CMakeLists.txt",
|
||||
@@ -210,8 +208,7 @@ describe("reference source import behavior", () => {
|
||||
policy: { secretPatterns: [] },
|
||||
});
|
||||
|
||||
expect(result.ok).toBe(true);
|
||||
if (!result.ok) return;
|
||||
if (!result.ok) throw result.error;
|
||||
// The importer always reports one standing advisory about pathname races,
|
||||
// so completeness is asserted per entry rather than globally.
|
||||
const limited = result.value.entries.filter(
|
||||
@@ -262,8 +259,7 @@ describe("reference source import behavior", () => {
|
||||
),
|
||||
);
|
||||
const result = await importTree(root);
|
||||
expect(result.ok).toBe(true);
|
||||
if (!result.ok) return;
|
||||
if (!result.ok) throw result.error;
|
||||
expect(result.value.entries.map(({ path }) => path)).toEqual(paths);
|
||||
const repeated = await importTree(root);
|
||||
expect(repeated).toEqual(result);
|
||||
@@ -351,8 +347,7 @@ describe("reference source path selection", () => {
|
||||
try {
|
||||
const root = await fixture(parent, "tree");
|
||||
const result = await importTree(root, undefined, []);
|
||||
expect(result.ok).toBe(true);
|
||||
if (!result.ok) return;
|
||||
if (!result.ok) throw result.error;
|
||||
expect(result.value.entries).toContainEqual(
|
||||
expect.objectContaining({
|
||||
path: ".env",
|
||||
@@ -382,8 +377,7 @@ describe("reference source rooted module specifiers", () => {
|
||||
"export const value = 1;\n",
|
||||
);
|
||||
const result = await importTree(root);
|
||||
expect(result.ok).toBe(true);
|
||||
if (!result.ok) return;
|
||||
if (!result.ok) throw result.error;
|
||||
expect(result.value.relationships).toContainEqual({
|
||||
from_path: "src/main.js",
|
||||
to: "/outside/dep.js",
|
||||
|
||||
@@ -19,8 +19,7 @@ describe("readReferenceSource entries", () => {
|
||||
|
||||
const result = await readReferenceSource(root);
|
||||
|
||||
expect(result.ok).toBe(true);
|
||||
if (!result.ok) return;
|
||||
if (!result.ok) throw result.error;
|
||||
expect(result.value.entries.map(({ path }) => path)).toEqual([
|
||||
"a.js",
|
||||
"nested",
|
||||
@@ -53,8 +52,7 @@ describe("readReferenceSource entries", () => {
|
||||
|
||||
const result = await readReferenceSource(root);
|
||||
|
||||
expect(result.ok).toBe(true);
|
||||
if (!result.ok) return;
|
||||
if (!result.ok) throw result.error;
|
||||
expect(result.value.entries).toEqual([
|
||||
{
|
||||
status: "read",
|
||||
@@ -98,8 +96,7 @@ describe("readReferenceSource entries", () => {
|
||||
|
||||
const result = await readReferenceSource(root);
|
||||
|
||||
expect(result.ok).toBe(true);
|
||||
if (!result.ok) return;
|
||||
if (!result.ok) throw result.error;
|
||||
expect(result.value.bytesRead).toBe(size);
|
||||
expect(result.value.entries).toContainEqual(
|
||||
expect.objectContaining({
|
||||
@@ -120,8 +117,7 @@ describe("readReferenceSource entries", () => {
|
||||
|
||||
const result = await readReferenceSource(root);
|
||||
|
||||
expect(result.ok).toBe(true);
|
||||
if (!result.ok) return;
|
||||
if (!result.ok) throw result.error;
|
||||
const path = [...segments, "deep.txt"].join("/");
|
||||
expect(result.value.entries).toContainEqual(
|
||||
expect.objectContaining({ status: "read", kind: "file", path }),
|
||||
@@ -145,8 +141,7 @@ describe("readReferenceSource failures and exclusions", () => {
|
||||
},
|
||||
});
|
||||
|
||||
expect(result.ok).toBe(true);
|
||||
if (!result.ok) return;
|
||||
if (!result.ok) throw result.error;
|
||||
expect(checked).toEqual(["ignored", "kept"]);
|
||||
expect(result.value.entries.map(({ path }) => path)).toEqual(["kept"]);
|
||||
});
|
||||
|
||||
@@ -44,8 +44,7 @@ it("preserves recovered diagnostics and file evidence through filesystem import"
|
||||
caller: "reference-recovery-test",
|
||||
policy: { secretPatterns: [] },
|
||||
});
|
||||
expect(result.ok).toBe(true);
|
||||
if (!result.ok) return;
|
||||
if (!result.ok) throw result.error;
|
||||
const graph = result.value;
|
||||
expect(historicalSourceGraphSchema.safeParse(graph).success).toBe(true);
|
||||
expect(graph.entries.map(({ path }) => path)).toEqual([
|
||||
|
||||
@@ -28,8 +28,7 @@ it("imports test-suffixed filenames with unchanged paths, hashes, and languages"
|
||||
caller: "reference-test-filenames-test",
|
||||
policy: { secretPatterns: [] },
|
||||
});
|
||||
expect(result.ok).toBe(true);
|
||||
if (!result.ok) return;
|
||||
if (!result.ok) throw result.error;
|
||||
expect(result.value.entries).toHaveLength(files.length);
|
||||
for (const [path, content, classifications, language] of files) {
|
||||
expect(result.value.entries).toContainEqual({
|
||||
@@ -70,8 +69,7 @@ it("keeps parser failures and unknown dependencies visible for test filenames",
|
||||
caller: "reference-test-parsing-test",
|
||||
policy: { secretPatterns: [] },
|
||||
});
|
||||
expect(result.ok).toBe(true);
|
||||
if (!result.ok) return;
|
||||
if (!result.ok) throw result.error;
|
||||
expect(result.value.inventory_state).toBe("partial");
|
||||
expect(result.value.relationships).toEqual([
|
||||
{
|
||||
|
||||
@@ -36,8 +36,7 @@ it.each([
|
||||
caller: "native-typescript-source",
|
||||
policy: { secretPatterns: [] },
|
||||
});
|
||||
expect(imported.ok).toBe(true);
|
||||
if (!imported.ok) return;
|
||||
if (!imported.ok) throw imported.error;
|
||||
expect(imported.value.relationships).toContainEqual({
|
||||
from_path: from,
|
||||
to: target,
|
||||
@@ -62,8 +61,7 @@ it.each(["main.ts", "main.js"])(
|
||||
caller: "native-typescript-source",
|
||||
policy: { secretPatterns: [] },
|
||||
});
|
||||
expect(imported.ok).toBe(true);
|
||||
if (!imported.ok) return;
|
||||
if (!imported.ok) throw imported.error;
|
||||
expect(imported.value.relationships).toContainEqual(
|
||||
expect.objectContaining({
|
||||
from_path: from,
|
||||
@@ -85,8 +83,7 @@ it("does not substitute TypeScript sources for a JavaScript runtime import", asy
|
||||
caller: "native-typescript-source",
|
||||
policy: { secretPatterns: [] },
|
||||
});
|
||||
expect(imported.ok).toBe(true);
|
||||
if (!imported.ok) return;
|
||||
if (!imported.ok) throw imported.error;
|
||||
expect(imported.value.relationships).toContainEqual(
|
||||
expect.objectContaining({
|
||||
from_path: "main.js",
|
||||
|
||||
Reference in New Issue
Block a user