MCPcopy
hub / github.com/rohitg00/agentmemory / mockKV

Function mockKV

test/slots.test.ts:5–24  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3import { KV } from "../src/state/schema.js";
4
5function mockKV() {
6 const store = new Map<string, Map<string, unknown>>();
7 return {
8 get: async <T>(scope: string, key: string): Promise<T | null> => {
9 return (store.get(scope)?.get(key) as T) ?? null;
10 },
11 set: async <T>(scope: string, key: string, data: T): Promise<T> => {
12 if (!store.has(scope)) store.set(scope, new Map());
13 store.get(scope)!.set(key, data);
14 return data;
15 },
16 delete: async (scope: string, key: string): Promise<void> => {
17 store.get(scope)?.delete(key);
18 },
19 list: async <T>(scope: string): Promise<T[]> => {
20 if (!store.has(scope)) return [];
21 return Array.from(store.get(scope)!.values()) as T[];
22 },
23 };
24}
25
26function wire() {
27 const kv = mockKV();

Callers 1

wireFunction · 0.70

Calls 4

hasMethod · 0.80
getMethod · 0.45
setMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected