accounts/server/config/config_test.go
2025-08-09 14:24:31 +08:00

31 lines
697 B
Go

package config
import (
"os"
"testing"
)
// TestLoad ensures the configuration file is loaded correctly.
func TestLoad(t *testing.T) {
wd, err := os.Getwd()
if err != nil {
t.Fatalf("getwd: %v", err)
}
// change to repository root so Load can read server/config/server.yaml
if err := os.Chdir("../.."); err != nil {
t.Fatalf("chdir: %v", err)
}
t.Cleanup(func() { os.Chdir(wd) })
cfg, err := Load()
if err != nil {
t.Fatalf("Load returned error: %v", err)
}
if cfg.Global.Redis.Addr != "127.0.0.1:6379" {
t.Fatalf("unexpected redis addr %q", cfg.Global.Redis.Addr)
}
if cfg.API.AskAI.Timeout != 100 {
t.Fatalf("unexpected askai timeout %d", cfg.API.AskAI.Timeout)
}
}