refactor: 解决无法正确加载 .env 的问题

This commit is contained in:
2026-04-20 15:54:40 +08:00
parent 181edf418e
commit d967e74125
2 changed files with 47 additions and 5 deletions
+23
View File
@@ -0,0 +1,23 @@
package config
import (
"testing"
)
func TestLoad(t *testing.T) {
cfg, err := Load()
if err != nil {
t.Fatalf("Load() failed: %v", err)
}
if cfg.Server.Port == "" {
t.Error("Expected Server.Port to have default value")
}
if cfg.LLM.Provider == "" && cfg.LLM.APIKey == "" {
t.Logf("Config loaded - some optional values may be empty (expected if .env not found)")
} else {
t.Logf("Config loaded successfully. Provider: %s, Model: %s",
cfg.LLM.Provider, cfg.LLM.Model)
}
}