1package configv2
2
3import (
4 "encoding/json"
5 "fmt"
6 "os"
7 "testing"
8
9 "github.com/stretchr/testify/assert"
10)
11
12func resetEnvVars() {
13 os.Setenv("ANTHROPIC_API_KEY", "")
14 os.Setenv("OPENAI_API_KEY", "")
15 os.Setenv("GEMINI_API_KEY", "")
16 os.Setenv("XAI_API_KEY", "")
17 os.Setenv("OPENROUTER_API_KEY", "")
18}
19
20func TestConfigWithEnv(t *testing.T) {
21 resetEnvVars()
22 testConfigDir = t.TempDir()
23
24 cwdDir := t.TempDir()
25
26 os.Setenv("ANTHROPIC_API_KEY", "test-anthropic-key")
27 os.Setenv("OPENAI_API_KEY", "test-openai-key")
28 os.Setenv("GEMINI_API_KEY", "test-gemini-key")
29 os.Setenv("XAI_API_KEY", "test-xai-key")
30 os.Setenv("OPENROUTER_API_KEY", "test-openrouter-key")
31 cfg := InitConfig(cwdDir)
32 data, _ := json.MarshalIndent(cfg, "", " ")
33 fmt.Println(string(data))
34 assert.Len(t, cfg.Providers, 5)
35}