mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-30 13:05:04 +00:00
perf(test): lighten models list e2e registry mock
This commit is contained in:
@@ -50,41 +50,34 @@ vi.mock("../agents/model-auth.js", () => ({
|
||||
}));
|
||||
|
||||
vi.mock("@mariozechner/pi-coding-agent", async () => {
|
||||
const actual = await vi.importActual<typeof import("@mariozechner/pi-coding-agent")>(
|
||||
"@mariozechner/pi-coding-agent",
|
||||
);
|
||||
|
||||
class MockAuthStorage {}
|
||||
|
||||
class MockModelRegistry {
|
||||
find(provider: string, id: string): ReturnType<typeof actual.ModelRegistry.prototype.find> {
|
||||
find(provider: string, id: string) {
|
||||
const found =
|
||||
modelRegistryState.models.find((model) => model.provider === provider && model.id === id) ??
|
||||
null;
|
||||
return found as ReturnType<typeof actual.ModelRegistry.prototype.find>;
|
||||
return found;
|
||||
}
|
||||
|
||||
getAll(): ReturnType<typeof actual.ModelRegistry.prototype.getAll> {
|
||||
getAll() {
|
||||
if (modelRegistryState.getAllError !== undefined) {
|
||||
throw modelRegistryState.getAllError;
|
||||
}
|
||||
return modelRegistryState.models as ReturnType<typeof actual.ModelRegistry.prototype.getAll>;
|
||||
return modelRegistryState.models;
|
||||
}
|
||||
|
||||
getAvailable(): ReturnType<typeof actual.ModelRegistry.prototype.getAvailable> {
|
||||
getAvailable() {
|
||||
if (modelRegistryState.getAvailableError !== undefined) {
|
||||
throw modelRegistryState.getAvailableError;
|
||||
}
|
||||
return modelRegistryState.available as ReturnType<
|
||||
typeof actual.ModelRegistry.prototype.getAvailable
|
||||
>;
|
||||
return modelRegistryState.available;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
...actual,
|
||||
AuthStorage: MockAuthStorage as unknown as typeof actual.AuthStorage,
|
||||
ModelRegistry: MockModelRegistry as unknown as typeof actual.ModelRegistry,
|
||||
AuthStorage: MockAuthStorage,
|
||||
ModelRegistry: MockModelRegistry,
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user