Files
mem0/integrations/eve/tests/idempotency.test.ts
T
Himanshu-SangshettiandCursor 1d83bb0835 feat(integrations): add @mem0/eve memory provider
Give Eve agents a first-class Mem0 recall/capture provider so they can use Mem0 in the agent loop instead of MCP.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-09 10:01:26 +08:00

33 lines
814 B
TypeScript

import { describe, expect, it } from "vitest";
import { createIdempotencyGate } from "../src/idempotency.js";
describe("createIdempotencyGate", () => {
it("runs work once per operation id", async () => {
const once = createIdempotencyGate();
let calls = 0;
const work = async () => {
calls += 1;
};
await Promise.all([once("op_1", work), once("op_1", work)]);
await once("op_1", work);
expect(calls).toBe(1);
});
it("retries after a failure", async () => {
const once = createIdempotencyGate();
let calls = 0;
const work = async () => {
calls += 1;
if (calls === 1) {
throw new Error("nope");
}
};
await expect(once("op_1", work)).rejects.toThrow("nope");
await once("op_1", work);
expect(calls).toBe(2);
});
});