mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-24 07:31:44 +00:00
36 lines
747 B
TypeScript
36 lines
747 B
TypeScript
export function createDirectoryTestRuntime() {
|
|
return {
|
|
log: () => {},
|
|
error: () => {},
|
|
exit: (code: number): never => {
|
|
throw new Error(`exit ${code}`);
|
|
},
|
|
};
|
|
}
|
|
|
|
type DirectoryMethod = (params: Record<string, unknown>) => Promise<unknown>;
|
|
|
|
export function expectDirectorySurface(
|
|
directory:
|
|
| {
|
|
listPeers?: unknown;
|
|
listGroups?: unknown;
|
|
}
|
|
| null
|
|
| undefined,
|
|
) {
|
|
if (!directory) {
|
|
throw new Error("expected directory");
|
|
}
|
|
if (!directory.listPeers) {
|
|
throw new Error("expected listPeers");
|
|
}
|
|
if (!directory.listGroups) {
|
|
throw new Error("expected listGroups");
|
|
}
|
|
return directory as {
|
|
listPeers: DirectoryMethod;
|
|
listGroups: DirectoryMethod;
|
|
};
|
|
}
|