mirror of
https://github.com/morluto/rea.git
synced 2026-11-19 21:23:45 +00:00
test: retain completed binary observations on late cancellation
This commit is contained in:
1 parent
ddb8abf855
commit
b899c35419
8 files changed
+88
-32
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { parseEvidence } from "../../domain/evidence.js";
|
||||
import { expect, it } from "vitest";
|
||||
import { NativeInitializersService } from "./NativeInitializersService.js";
|
||||
import { NATIVE_INITIALIZERS_PROVIDER } from "../../domain/investigationProviders.js";
|
||||
@@ -113,12 +114,13 @@ it("rejects a slot offset outside the artifact", async () => {
|
||||
if (!result.ok) expect(result.error).toBeInstanceOf(AnalysisOutputError);
|
||||
});
|
||||
|
||||
it("discards an observation if the caller cancels while the provider completes", async () => {
|
||||
it("retains a completed observation when the caller cancels as the provider completes", async () => {
|
||||
const controller = new AbortController();
|
||||
const reason = { request: "late NativeInitializers cancellation" };
|
||||
const service = new NativeInitializersService({
|
||||
identity,
|
||||
inspect: () => {
|
||||
controller.abort();
|
||||
controller.abort(reason);
|
||||
return Promise.resolve(ok(report));
|
||||
},
|
||||
});
|
||||
@@ -126,6 +128,11 @@ it("discards an observation if the caller cancels while the provider completes",
|
||||
{ path: report.artifact.path },
|
||||
{ signal: controller.signal },
|
||||
);
|
||||
expect(result.ok).toBe(false);
|
||||
if (!result.ok) expect(result.error).toBeInstanceOf(AnalysisCancelledError);
|
||||
if (result.ok) throw new Error("Expected late cancellation");
|
||||
expect(result.error).toBeInstanceOf(AnalysisCancelledError);
|
||||
expect(result.error.cause).toBe(reason);
|
||||
expect(parseEvidence(result.error.partialObservation)).toMatchObject({
|
||||
operation: "inspect_native_initializers",
|
||||
normalized_result: report,
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user