Files
backend/pkg/config/manager_test.go
lafay 7d1c78f965
Some checks failed
Build / build (push) Successful in 7m52s
Build / build-docker (push) Has been cancelled
refactor: 移除全局单例、修复分层违规、统一错误与响应
2026-06-15 16:40:36 +08:00

23 lines
545 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package config
import (
"testing"
)
// TestLoad_Config 验证 Load() 能成功加载配置(从环境变量/默认值)
// 全局单例访问器GetConfig/MustGetConfig已在 DI 迁移中移除,
// 配置通过 config.Load() 加载并由 fx.Supply 注入。
func TestLoad_Config(t *testing.T) {
cfg, err := Load()
if err != nil {
t.Fatalf("Load() 返回错误: %v", err)
}
if cfg == nil {
t.Fatal("Load() 返回 nil 配置")
}
// 验证默认值生效
if cfg.Server.Port == "" {
t.Error("Server.Port 不应为空")
}
}