test(lint): typa idempotency-store i stället för any (blockerar quality-gaten)
masterplan-lock / check (push) Successful in 4s
CI (SIAX Cloud) / sonar (pull_request) Skipped
masterplan-lock / check (pull_request) Successful in 7s
Security Scan (SIAX Cloud) / security (pull_request) Successful in 15s
CI (SIAX Cloud) / Component conformance (blocking) (pull_request) Successful in 15s
CI (SIAX Cloud) / security (pull_request) Successful in 21s
CI (SIAX Cloud) / integration (pull_request) Successful in 1m7s
CI (SIAX Cloud) / quality (pull_request) Successful in 1m22s
masterplan-lock / check (push) Successful in 4s
CI (SIAX Cloud) / sonar (pull_request) Skipped
masterplan-lock / check (pull_request) Successful in 7s
Security Scan (SIAX Cloud) / security (pull_request) Successful in 15s
CI (SIAX Cloud) / Component conformance (blocking) (pull_request) Successful in 15s
CI (SIAX Cloud) / security (pull_request) Successful in 21s
CI (SIAX Cloud) / integration (pull_request) Successful in 1m7s
CI (SIAX Cloud) / quality (pull_request) Successful in 1m22s
tests/siax-access/idempotency.test.ts hade fyra @typescript-eslint/no-explicit-any
vilket fick quality-jobbet att exita 1 (133 testfiler gröna men lint röd) och
därmed blockerade alla PR:er. Använder exporterade IdempotencyStore<unknown,
{x:number}>; eslint rent, 7/7 tester gröna.
This commit is contained in:
@@ -1,5 +1,10 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
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", () => {
|
describe("@siax/access universal idempotency", () => {
|
||||||
it("binds every result-affecting input into the fingerprint", () => {
|
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 () => {
|
it("replays a stored receipt verbatim on the exact fingerprint", async () => {
|
||||||
const stored = { x: 1 };
|
const stored = { x: 1 };
|
||||||
const store: any = {
|
const store: IdempotencyStore<unknown, { x: number }> = {
|
||||||
start: async () => false,
|
start: async () => false,
|
||||||
save: async () => {},
|
save: async () => {},
|
||||||
receipt: async () => stored,
|
receipt: async () => stored,
|
||||||
@@ -32,7 +37,7 @@ describe("@siax/access universal idempotency", () => {
|
|||||||
});
|
});
|
||||||
it("claims once and saves only after the dispatch", async () => {
|
it("claims once and saves only after the dispatch", async () => {
|
||||||
const order: string[] = [];
|
const order: string[] = [];
|
||||||
const store: any = {
|
const store: IdempotencyStore<unknown, { x: number }> = {
|
||||||
start: async () => { order.push("start"); return true; },
|
start: async () => { order.push("start"); return true; },
|
||||||
save: async () => { order.push("save"); },
|
save: async () => { order.push("save"); },
|
||||||
receipt: async () => { order.push("receipt"); return undefined; },
|
receipt: async () => { order.push("receipt"); return undefined; },
|
||||||
@@ -47,7 +52,7 @@ describe("@siax/access universal idempotency", () => {
|
|||||||
expect(order).toEqual(["start", "dispatch", "save"]);
|
expect(order).toEqual(["start", "dispatch", "save"]);
|
||||||
});
|
});
|
||||||
it("reports a store error as conflict, never as a fresh start", async () => {
|
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"); },
|
start: async () => { throw new Error("db down"); },
|
||||||
save: async () => {},
|
save: async () => {},
|
||||||
receipt: async () => { throw new Error("db down"); },
|
receipt: async () => { throw new Error("db down"); },
|
||||||
@@ -61,7 +66,7 @@ describe("@siax/access universal idempotency", () => {
|
|||||||
expect(dispatched).toBe(0);
|
expect(dispatched).toBe(0);
|
||||||
});
|
});
|
||||||
it("does not rerun the dispatch when start succeeds but save later fails", async () => {
|
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;
|
let dispatched = 0;
|
||||||
const outcome = await runIdempotentOperation({
|
const outcome = await runIdempotentOperation({
|
||||||
store, identity: {}, fingerprint: "fp",
|
store, identity: {}, fingerprint: "fp",
|
||||||
|
|||||||
Reference in New Issue
Block a user