mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 22:24:32 +00:00
refactor(test): dedupe provider env setup in model config tests
This commit is contained in:
@@ -2,21 +2,16 @@ import { mkdtempSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { captureEnv } from "../test-utils/env.js";
|
||||
import { withEnvAsync } from "../test-utils/env.js";
|
||||
import { resolveImplicitProviders } from "./models-config.providers.js";
|
||||
|
||||
describe("Qianfan provider", () => {
|
||||
it("should include qianfan when QIANFAN_API_KEY is configured", async () => {
|
||||
const agentDir = mkdtempSync(join(tmpdir(), "openclaw-test-"));
|
||||
const envSnapshot = captureEnv(["QIANFAN_API_KEY"]);
|
||||
process.env.QIANFAN_API_KEY = "test-key";
|
||||
|
||||
try {
|
||||
await withEnvAsync({ QIANFAN_API_KEY: "test-key" }, async () => {
|
||||
const providers = await resolveImplicitProviders({ agentDir });
|
||||
expect(providers?.qianfan).toBeDefined();
|
||||
expect(providers?.qianfan?.apiKey).toBe("QIANFAN_API_KEY");
|
||||
} finally {
|
||||
envSnapshot.restore();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user