mirror of
https://github.com/morluto/rea.git
synced 2026-11-10 00:36:35 +00:00
* test: focus configuration diagnostics on their owners Preserve shape errors, selected paths, recovery guidance, and unchanged-file behavior across parser, setup, and uninstall boundaries. * test: focus artifact and evidence checks on behavior Retain format, identity, malformed-input, and cleanup coverage while removing fixed prose and closing the admitted test source. * refactor(debugger): use configured session admission limits * test: focus evidence and diagnostics on behavior * fix(test): restore verifier export and formatting * test(config): verify debugger limit ranges * test(rizin): keep fixture executable authoritative * test(rizin): isolate debugger fixture environment
73 lines
2.4 KiB
TypeScript
73 lines
2.4 KiB
TypeScript
import { expect } from "vitest";
|
|
import type { AnalysisError } from "../../src/domain/analysisErrorBase.js";
|
|
import {
|
|
AnalysisCancelledError,
|
|
AnalysisOutputError,
|
|
} from "../../src/domain/analysisErrorCore.js";
|
|
import { projectAnalysisError } from "../../src/domain/analysisErrorProjection.js";
|
|
import type { Result } from "../../src/domain/result.js";
|
|
|
|
/** Assert the service returned the same owner error and its cause. */
|
|
export const expectOwnerError = <T>(
|
|
result: Result<T, AnalysisError>,
|
|
failure: AnalysisError,
|
|
cause: unknown,
|
|
): AnalysisError => {
|
|
expect(result.ok).toBe(false);
|
|
if (result.ok) throw new Error("Expected the owner failure");
|
|
expect(result.error).toBe(failure);
|
|
expect(result.error.cause).toBe(cause);
|
|
return result.error;
|
|
};
|
|
|
|
/** A JSON-safe incomplete observation stays on the owner error. */
|
|
export const expectKeptPartial = (
|
|
error: AnalysisError,
|
|
partial: unknown,
|
|
code: "cancelled" | "provider_timeout" = "cancelled",
|
|
): void => {
|
|
expect(error.partialObservation).toEqual(partial);
|
|
expect(error.secondaryFailures).toHaveLength(0);
|
|
expect(projectAnalysisError(error)).toMatchObject({
|
|
code,
|
|
details: { partial_observation: partial },
|
|
});
|
|
};
|
|
|
|
/** A completed value failed output validation, including after a late abort. */
|
|
export const expectOutputError = (
|
|
result: Result<unknown, AnalysisError>,
|
|
): void => {
|
|
expect(result).toMatchObject({
|
|
ok: false,
|
|
error: { _tag: "AnalysisOutputError" },
|
|
});
|
|
if (!result.ok) expect(result.error).toBeInstanceOf(AnalysisOutputError);
|
|
};
|
|
|
|
/** Cancellation won before the provider ran. */
|
|
export const expectPreemptedCancellation = (
|
|
result: Result<unknown, AnalysisError>,
|
|
cause: unknown,
|
|
providerCalls: number,
|
|
): void => {
|
|
expect(result.ok).toBe(false);
|
|
if (result.ok) throw new Error("Expected cancellation");
|
|
expect(result.error).toBeInstanceOf(AnalysisCancelledError);
|
|
expect(result.error.cause).toBe(cause);
|
|
expect(providerCalls).toBe(0);
|
|
};
|
|
|
|
/** A non-JSON partial is cleared and recorded as a secondary output failure. */
|
|
export const expectDroppedPartial = (
|
|
error: AnalysisError,
|
|
reason: string,
|
|
code: "cancelled" | "provider_timeout" = "cancelled",
|
|
): void => {
|
|
expect(error.partialObservation).toBeUndefined();
|
|
expect(error.secondaryFailures).toMatchObject([
|
|
{ _tag: "AnalysisOutputError", reason },
|
|
]);
|
|
expect(projectAnalysisError(error).code).toBe(code);
|
|
};
|