mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-30 03:11:10 +00:00
refactor: trim models-config test async wrappers
This commit is contained in:
@@ -4,7 +4,7 @@ import type { OpenClawConfig } from "../config/config.js";
|
||||
import type { MockFn } from "../test-utils/vitest-mock-fn.js";
|
||||
import { resolveImplicitProviders } from "./models-config.providers.implicit.js";
|
||||
|
||||
export async function withModelsTempHome<T>(fn: (home: string) => Promise<T>): Promise<T> {
|
||||
export function withModelsTempHome<T>(fn: (home: string) => Promise<T>): Promise<T> {
|
||||
return withTempHomeBase(fn, { prefix: "openclaw-models-" });
|
||||
}
|
||||
|
||||
@@ -145,10 +145,10 @@ export function snapshotImplicitProviderEnv(env?: NodeJS.ProcessEnv): NodeJS.Pro
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
export async function resolveImplicitProvidersForTest(
|
||||
export function resolveImplicitProvidersForTest(
|
||||
params: Parameters<typeof resolveImplicitProviders>[0],
|
||||
) {
|
||||
return await resolveImplicitProviders({
|
||||
return resolveImplicitProviders({
|
||||
...params,
|
||||
env: snapshotImplicitProviderEnv(params.env),
|
||||
});
|
||||
|
||||
@@ -71,7 +71,7 @@ async function resolveChutesProvidersForProfiles(
|
||||
) {
|
||||
const agentDir = createTempAgentDir();
|
||||
await writeChutesAuthProfiles(agentDir, profiles);
|
||||
return await resolveImplicitProvidersForTest({ agentDir, env });
|
||||
return resolveImplicitProvidersForTest({ agentDir, env });
|
||||
}
|
||||
|
||||
function expectChutesApiKeyProvider(
|
||||
|
||||
@@ -61,7 +61,7 @@ describe("Ollama provider", () => {
|
||||
}
|
||||
|
||||
async function resolveProvidersWithOllamaKey(agentDir: string) {
|
||||
return await withOllamaApiKey(async () => await resolveImplicitProvidersForTest({ agentDir }));
|
||||
return withOllamaApiKey(() => resolveImplicitProvidersForTest({ agentDir }));
|
||||
}
|
||||
|
||||
const createTagModel = (name: string) => ({ name, modified_at: "", size: 1, digest: "" });
|
||||
|
||||
Reference in New Issue
Block a user