test(agent): time the connector registry against a store without spies (P1.2)

This commit is contained in:
shumeiko.it
2026-10-24 17:24:47 +02:00
parent 316cb2ba36
commit d51ea0aed5
2 changed files with 20 additions and 14 deletions

View File

@@ -30,6 +30,21 @@ export interface SecretStoreSeed {
* The seed is written before the spies exist, so it does not show up in their calls.
*/
export function createMemorySecretStore(seed: SecretStoreSeed = {}): MockSecretStore {
const store = createPlainSecretStore(seed);
return {
get: vi.fn(store.get),
set: vi.fn(store.set),
setAsync: vi.fn(store.setAsync),
writeBatch: vi.fn(store.writeBatch),
delete: vi.fn(store.delete),
deleteAsync: vi.fn(store.deleteAsync),
list: vi.fn(store.list),
has: vi.fn(store.has),
};
}
/** The same Map-backed store without spies, for timing tests. */
export function createPlainSecretStore(seed: SecretStoreSeed = {}): SecretStore {
const entries = new Map<string, SecretEntry>();
const store: SecretStore = {
get: name => entries.get(name) ?? null,
@@ -53,15 +68,5 @@ export function createMemorySecretStore(seed: SecretStoreSeed = {}): MockSecretS
for (const [name, value] of Object.entries(seed.secrets ?? {})) {
store.set(name, value);
}
return {
get: vi.fn(store.get),
set: vi.fn(store.set),
setAsync: vi.fn(store.setAsync),
writeBatch: vi.fn(store.writeBatch),
delete: vi.fn(store.delete),
deleteAsync: vi.fn(store.deleteAsync),
list: vi.fn(store.list),
has: vi.fn(store.has),
};
return store;
}