Files
penguin-harness/packages/core/test/provider-keys.ts
T
Yaowei Zheng 45bfae6e94 Initialize repository with harness code and assets
Initial import of all source code, config, and README assets: the
packages workspace (cli, core, server, web, docs, landing, skills),
build scripts, tooling config, and CI workflows.

Includes the data-layout revision made on this branch: the local data
root defaults to ~/.penguin/data (PENGUIN_HOME still overrides; the
installer keeps its binaries in ~/.penguin), and every Agent lives
under <project>/agents/<agent>/ — path helpers, the three
agent-enumeration scans, the system prompt, built-in Skills, tests
and docs all follow the new layout.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018ihk8iQuo3kv2aPjAYEPuR
2026-07-19 14:06:53 +08:00

25 lines
1.1 KiB
TypeScript

/**
* Fake API keys for testing: the provider SDK requires a credential at **construction time**
* (throwing "Missing credentials" if absent), and `createSession` constructs an LLM client for
* the default model.
*
* The default model uses the OpenAI protocol (DeepSeek), so `OPENAI_API_KEY` must have a value;
* Anthropic's is stubbed too, for test cases that explicitly specify a claude model. The keys
* are only used to construct the client; tests never actually send a request. CI has no keys
* at all, while most local dev machines do -- without stubbing, tests would "pass locally,
* fail in CI."
*/
const KEYS = ["OPENAI_API_KEY", "ANTHROPIC_API_KEY"] as const;
/** Stubs in fake keys and returns a restore function (call it in afterEach). */
export function stubProviderKeys(): () => void {
const prev = KEYS.map((k) => [k, process.env[k]] as const);
for (const k of KEYS) process.env[k] = "test-key-not-used";
return () => {
for (const [k, v] of prev) {
if (v === undefined) delete process.env[k];
else process.env[k] = v;
}
};
}