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.
|
* The seed is written before the spies exist, so it does not show up in their calls.
|
||||||
*/
|
*/
|
||||||
export function createMemorySecretStore(seed: SecretStoreSeed = {}): MockSecretStore {
|
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 entries = new Map<string, SecretEntry>();
|
||||||
const store: SecretStore = {
|
const store: SecretStore = {
|
||||||
get: name => entries.get(name) ?? null,
|
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 ?? {})) {
|
for (const [name, value] of Object.entries(seed.secrets ?? {})) {
|
||||||
store.set(name, value);
|
store.set(name, value);
|
||||||
}
|
}
|
||||||
|
return store;
|
||||||
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),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ import { composePersonaPrompt, PERSONAS, getPersona } from '../../src/personas.j
|
|||||||
import { AgentMessageBus } from '../../src/agent-message-bus.js';
|
import { AgentMessageBus } from '../../src/agent-message-bus.js';
|
||||||
import { needsConfirmation, getApprovalClass } from '../../src/confirmation.js';
|
import { needsConfirmation, getApprovalClass } from '../../src/confirmation.js';
|
||||||
import { WorkspaceSessionManager } from '../../../server/src/local/workspace-sessions.js';
|
import { WorkspaceSessionManager } from '../../../server/src/local/workspace-sessions.js';
|
||||||
import { createMemorySecretStore, type MockSecretStore } from '../helpers/memory-secret-store.js';
|
import type { SecretStore } from '@waggle/core';
|
||||||
|
import { createPlainSecretStore } from '../helpers/memory-secret-store.js';
|
||||||
// The session manager is typed against the published @waggle/agent surface.
|
// The session manager is typed against the published @waggle/agent surface.
|
||||||
import type { Orchestrator } from '@waggle/agent';
|
import type { Orchestrator } from '@waggle/agent';
|
||||||
import type { ConnectorHealth } from '@waggle/shared';
|
import type { ConnectorHealth } from '@waggle/shared';
|
||||||
@@ -50,8 +51,8 @@ class PerfConnector extends BaseConnector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createMockVault(connectedIds: string[]): MockSecretStore {
|
function createMockVault(connectedIds: string[]): SecretStore {
|
||||||
return createMemorySecretStore({
|
return createPlainSecretStore({
|
||||||
connectors: Object.fromEntries(connectedIds.map(id => [id, { type: 'bearer' as const, value: 'tok' }])),
|
connectors: Object.fromEntries(connectedIds.map(id => [id, { type: 'bearer' as const, value: 'tok' }])),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user