Merge pull request 'test(lint): typa idempotency-store (fixar quality-gaten som blockerar alla PR)' (#503) from fix/lint-siax-access-idempotency into main
masterplan-lock / check (push) Successful in 4s
CI (SIAX Cloud) / security (push) Successful in 23s
CI (SIAX Cloud) / Component conformance (blocking) (push) Successful in 26s
Security Scan (SIAX Cloud) / security (push) Successful in 37s
CI (SIAX Cloud) / sonar (push) Successful in 1m22s
Release chain (G17, ADR-W16-003) / Build, push, G17 (SBOM/scan/attest/verify/evidence) (push) Successful in 2m48s
Deploy to Coolify / deploy (push) Successful in 2m55s
CI (SIAX Cloud) / integration (push) Successful in 9m58s
CI (SIAX Cloud) / quality (push) Successful in 10m34s
masterplan-lock / check (push) Successful in 4s
CI (SIAX Cloud) / security (push) Successful in 23s
CI (SIAX Cloud) / Component conformance (blocking) (push) Successful in 26s
Security Scan (SIAX Cloud) / security (push) Successful in 37s
CI (SIAX Cloud) / sonar (push) Successful in 1m22s
Release chain (G17, ADR-W16-003) / Build, push, G17 (SBOM/scan/attest/verify/evidence) (push) Successful in 2m48s
Deploy to Coolify / deploy (push) Successful in 2m55s
CI (SIAX Cloud) / integration (push) Successful in 9m58s
CI (SIAX Cloud) / quality (push) Successful in 10m34s
This commit was merged in pull request #503.
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { operationFingerprint, operationIdentity, runIdempotentOperation } from "../../packages/siax-access/src/idempotency";
|
||||
import {
|
||||
operationFingerprint,
|
||||
operationIdentity,
|
||||
runIdempotentOperation,
|
||||
type IdempotencyStore,
|
||||
} from "../../packages/siax-access/src/idempotency";
|
||||
|
||||
describe("@siax/access universal idempotency", () => {
|
||||
it("binds every result-affecting input into the fingerprint", () => {
|
||||
@@ -18,7 +23,7 @@ describe("@siax/access universal idempotency", () => {
|
||||
});
|
||||
it("replays a stored receipt verbatim on the exact fingerprint", async () => {
|
||||
const stored = { x: 1 };
|
||||
const store: any = {
|
||||
const store: IdempotencyStore<unknown, { x: number }> = {
|
||||
start: async () => false,
|
||||
save: async () => {},
|
||||
receipt: async () => stored,
|
||||
@@ -32,7 +37,7 @@ describe("@siax/access universal idempotency", () => {
|
||||
});
|
||||
it("claims once and saves only after the dispatch", async () => {
|
||||
const order: string[] = [];
|
||||
const store: any = {
|
||||
const store: IdempotencyStore<unknown, { x: number }> = {
|
||||
start: async () => { order.push("start"); return true; },
|
||||
save: async () => { order.push("save"); },
|
||||
receipt: async () => { order.push("receipt"); return undefined; },
|
||||
@@ -47,7 +52,7 @@ describe("@siax/access universal idempotency", () => {
|
||||
expect(order).toEqual(["start", "dispatch", "save"]);
|
||||
});
|
||||
it("reports a store error as conflict, never as a fresh start", async () => {
|
||||
const store: any = {
|
||||
const store: IdempotencyStore<unknown, { x: number }> = {
|
||||
start: async () => { throw new Error("db down"); },
|
||||
save: async () => {},
|
||||
receipt: async () => { throw new Error("db down"); },
|
||||
@@ -61,7 +66,7 @@ describe("@siax/access universal idempotency", () => {
|
||||
expect(dispatched).toBe(0);
|
||||
});
|
||||
it("does not rerun the dispatch when start succeeds but save later fails", async () => {
|
||||
const store: any = { start: async () => true, save: async () => { throw new Error("journal write failed"); }, receipt: async () => undefined };
|
||||
const store: IdempotencyStore<unknown, { x: number }> = { start: async () => true, save: async () => { throw new Error("journal write failed"); }, receipt: async () => undefined };
|
||||
let dispatched = 0;
|
||||
const outcome = await runIdempotentOperation({
|
||||
store, identity: {}, fingerprint: "fp",
|
||||
|
||||
Reference in New Issue
Block a user