mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
fix: add LiteLLM to env overrides and fix malformed .env test
- Add missing LITELLM entry to loadProviderEnvOverrides so PICOCLAW_PROVIDERS_LITELLM_API_KEY/API_BASE env vars work - Replace valid .env content in TestLoadConfig_MalformedDotenv_NonFatal with genuinely malformed content (bare key without '=') to actually exercise the non-fatal error path Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -868,6 +868,7 @@ func loadProviderEnvOverrides(cfg *Config) {
|
||||
}{
|
||||
{"ANTHROPIC", &cfg.Providers.Anthropic.APIKey, &cfg.Providers.Anthropic.APIBase},
|
||||
{"OPENAI", &cfg.Providers.OpenAI.APIKey, &cfg.Providers.OpenAI.APIBase},
|
||||
{"LITELLM", &cfg.Providers.LiteLLM.APIKey, &cfg.Providers.LiteLLM.APIBase},
|
||||
{"OPENROUTER", &cfg.Providers.OpenRouter.APIKey, &cfg.Providers.OpenRouter.APIBase},
|
||||
{"GROQ", &cfg.Providers.Groq.APIKey, &cfg.Providers.Groq.APIBase},
|
||||
{"ZHIPU", &cfg.Providers.Zhipu.APIKey, &cfg.Providers.Zhipu.APIBase},
|
||||
|
||||
@@ -532,13 +532,14 @@ func TestLoadConfig_MalformedDotenv_NonFatal(t *testing.T) {
|
||||
t.Fatalf("WriteFile config: %v", err)
|
||||
}
|
||||
|
||||
// Write a malformed .env file (missing value after '=')
|
||||
// Write a .env file with genuinely malformed content (bare key without '=',
|
||||
// mixed with a valid line) to verify godotenv.Load errors are non-fatal.
|
||||
envFile := filepath.Join(dir, ".env")
|
||||
if err := os.WriteFile(envFile, []byte("VALID_KEY=valid_value\n"), 0o600); err != nil {
|
||||
if err := os.WriteFile(envFile, []byte("THIS_LINE_HAS_NO_EQUALS\nVALID_KEY=valid_value\n"), 0o600); err != nil {
|
||||
t.Fatalf("WriteFile .env: %v", err)
|
||||
}
|
||||
|
||||
// LoadConfig should not fail even with unusual .env content
|
||||
// LoadConfig should not fail even with malformed .env content
|
||||
cfg, err := LoadConfig(configPath)
|
||||
if err != nil {
|
||||
t.Fatalf("LoadConfig() should not fail with .env issues, got error: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user