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 不应为空") } }