2025-05-25 20:34:08 +08:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
2025-06-06 00:09:10 +08:00
|
|
|
"game/common/constant"
|
2025-05-25 20:34:08 +08:00
|
|
|
"github.com/fox/fox/db"
|
|
|
|
"github.com/fox/fox/log"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2025-06-06 00:09:10 +08:00
|
|
|
redisHost = "114.132.124.145"
|
|
|
|
//redisPort = "6379"
|
|
|
|
//redisPassword = "fox379@@zyxi"
|
|
|
|
specialKey = "test_config"
|
2025-05-25 20:34:08 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func initLog() {
|
|
|
|
log.Open("test.log", log.DebugL)
|
|
|
|
}
|
|
|
|
|
|
|
|
type specialConfig struct {
|
|
|
|
Rate int `json:"rate"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestConfig(t *testing.T) {
|
|
|
|
initLog()
|
2025-06-06 00:09:10 +08:00
|
|
|
rdb, err := db.InitRedis(redisPassword, redisHost, redisPort, constant.Redis0Config)
|
2025-05-25 20:34:08 +08:00
|
|
|
if err != nil {
|
|
|
|
log.Error(err.Error())
|
|
|
|
return
|
|
|
|
}
|
2025-06-06 00:09:10 +08:00
|
|
|
comm, err := LoadCommonConfig[specialConfig](rdb, "", "", "")
|
2025-05-25 20:34:08 +08:00
|
|
|
if err != nil {
|
|
|
|
log.Error(err.Error())
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if err = LoadSpecialConfig[specialConfig](rdb, specialKey, comm); err != nil {
|
|
|
|
log.Error(err.Error())
|
|
|
|
} else {
|
|
|
|
log.DebugF("load common config success:%#v", comm)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|