test: remove duplicate result assertions before throwing guards

This commit is contained in:
morluto
2026-10-09 02:58:03 +08:00
parent 5945915f91
commit a1b7d40bb0
33 changed files with 0 additions and 62 deletions
@@ -139,7 +139,6 @@ describe("analysis provider registry: binding failures and cancellation", () =>
const unsupported = await new AnalysisProviderRegistry([
candidate("alpha", { available: false }).provider,
]).select(ARTIFACT_TARGET, "alpha");
expect(unsupported.ok).toBe(false);
if (unsupported.ok)
throw new Error("expected unsupported target rejection");
expect(unsupported.error).toBeInstanceOf(ProviderSelectionError);
@@ -181,7 +180,6 @@ describe("analysis provider registry: binding failures and cancellation", () =>
});
}
const explicit = await automatic.select(ARTIFACT_TARGET, "alpha");
expect(explicit.ok).toBe(false);
if (explicit.ok) throw new Error("expected provider selection rejection");
expect(explicit.error).toBeInstanceOf(ProviderSelectionError);
if (explicit.error instanceof ProviderSelectionError)
@@ -213,7 +211,6 @@ describe("analysis provider registry: binding failures and cancellation", () =>
const explicit = await new AnalysisProviderRegistry([
failed.provider,
]).select(DATABASE_TARGET, "failed");
expect(explicit.ok).toBe(false);
if (explicit.ok) throw new Error("expected provider selection rejection");
expect(explicit.error).toBeInstanceOf(ProviderSelectionError);
if (explicit.error instanceof ProviderSelectionError)
@@ -230,7 +230,6 @@ describe("analysis snapshot cache partitioning", () => {
ANALYSIS_SNAPSHOT_PROFILE,
createEvidenceBundle([evidence]),
);
expect(exported.ok).toBe(true);
if (!exported.ok) throw new Error("snapshot export failed");
const tampered = structuredClone(exported.value);
const tamperedEntry = tampered.entries[0];
@@ -43,7 +43,6 @@ describe("JavaScript analysis cancellation before publication", () => {
},
);
expect(requested).toBe(true);
expect(result.ok).toBe(false);
if (result.ok)
throw new Error("Cancelled analysis must not publish Evidence");
expect(projectAnalysisError(result.error)).toMatchObject({
@@ -68,7 +67,6 @@ describe("JavaScript analysis cancellation before publication", () => {
},
},
);
expect(result.ok).toBe(false);
if (result.ok) throw new Error("Expected cancellation before admission");
expect(projectAnalysisError(result.error)).toMatchObject({
details: { reason: "cancelled" },
@@ -30,7 +30,6 @@ describe("JavaScript application failure diagnostics", () => {
},
);
expect(result.ok).toBe(false);
if (result.ok) throw new Error("Expected analysis failure");
expect(result.error.cause).toBe(cause);
expect(projectAnalysisError(result.error)).toMatchObject({
@@ -59,7 +58,6 @@ describe("JavaScript application failure diagnostics", () => {
},
},
);
expect(result.ok).toBe(false);
if (result.ok) throw new Error("Expected analysis failure");
expect(result.error.cause).toBe(cause);
expect(projectAnalysisError(result.error)).toMatchObject({
@@ -84,7 +82,6 @@ describe("JavaScript application failure diagnostics", () => {
input_path: join(root, "missing"),
format: "directory",
});
expect(result.ok).toBe(false);
if (result.ok) throw new Error("Expected missing artifact failure");
expect(projectAnalysisError(result.error)).toMatchObject({
code: "artifact_operation_failed",
@@ -107,7 +104,6 @@ describe("JavaScript application failure diagnostics", () => {
},
},
);
expect(result.ok).toBe(false);
if (result.ok) throw new Error("Expected analysis failure");
expect(projectAnalysisError(result.error)).toMatchObject({
code: "execution_failure",
@@ -140,7 +136,6 @@ describe("JavaScript application failure diagnostics", () => {
},
},
);
expect(result.ok).toBe(false);
if (result.ok) throw new Error("Expected analysis failure");
expect(projectAnalysisError(result.error)).toMatchObject({
code: "execution_failure",
@@ -61,7 +61,6 @@ describe("source-relative file URL paths", () => {
input_path: root,
format: "directory",
});
expect(result.ok).toBe(true);
if (!result.ok) throw result.error;
const { graph } = javascriptApplicationAnalysisResultSchema.parse(
result.value.normalized_result,
@@ -124,7 +124,6 @@ describe("ESM module URL decoding", () => {
input_path: root,
format: "directory",
});
expect(result.ok).toBe(true);
if (!result.ok) throw result.error;
const { graph } = javascriptApplicationAnalysisResultSchema.parse(
result.value.normalized_result,
@@ -235,7 +234,6 @@ describe("package exports URL paths", () => {
input_path: root,
format: "directory",
});
expect(result.ok).toBe(true);
if (!result.ok) throw result.error;
const { graph } = javascriptApplicationAnalysisResultSchema.parse(
result.value.normalized_result,
@@ -111,7 +111,6 @@ describe("JavaScript recovery workflow", () => {
),
});
const result = await service.recover(input);
expect(result.ok).toBe(false);
if (result.ok) throw new Error("expected invalid port output");
expect(result.error._tag).toBe("AnalysisOutputError");
});