The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 03:37 UTC
| 1 | // @effect-diagnostics nodeBuiltinImport:off |
| 2 | import * as NodeFS from "node:fs"; |
| 3 | import * as NodeOS from "node:os"; |
| 4 | import * as NodePath from "node:path"; |
| 5 | import { describe, expect, it, vi } from "vite-plus/test"; |
| 6 | import { proxyConfig } from "./proxy.ts"; |
| 7 | |
| 8 | const config = `model_provider = "cliproxy" |
| 9 | |
| 10 | [model_providers.cliproxy] |
| 11 | base_url = "https://proxy.example/v1" |
| 12 | requires_openai_auth = true |
| 13 | `; |
| 14 | |
| 15 | describe("proxyConfig", () => { |
| 16 | it.each([ |
| 17 | ["no auth.json", undefined], |
| 18 | ["a ChatGPT-login auth.json", { OPENAI_API_KEY: null, tokens: { access_token: "t" } }], |
| 19 | ])("fails when the provider requires OpenAI auth and %s has no key", (_, auth) => { |
| 20 | const home = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-evals-proxy-")); |
| 21 | using _home = { |
| 22 | [Symbol.dispose]: () => { |
| 23 | vi.unstubAllEnvs(); |
| 24 | NodeFS.rmSync(home, { recursive: true }); |
| 25 | }, |
| 26 | }; |
| 27 | NodeFS.writeFileSync(NodePath.join(home, "config.toml"), config); |
| 28 | if (auth) NodeFS.writeFileSync(NodePath.join(home, "auth.json"), JSON.stringify(auth)); |
| 29 | vi.stubEnv("CODEX_HOME", home); |
| 30 | expect(() => proxyConfig()).toThrow(/requires_openai_auth/); |
| 31 | }); |
| 32 | }); |