test(agent): time the connector registry against a store without spies (P1.2)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user