game/common/config/loadConfig_test.go

44 lines
827 B
Go

package config
import (
"game/common/constant"
"github.com/fox/fox/db"
"github.com/fox/fox/log"
"testing"
)
const (
redisHost = "114.132.124.145"
//redisPort = "6379"
//redisPassword = "fox379@@zyxi"
specialKey = "test_config"
)
func initLog() {
log.Open("test.log", log.DebugL)
}
type specialConfig struct {
Rate int `json:"rate"`
}
func TestConfig(t *testing.T) {
initLog()
rdb, err := db.InitRedis(redisPassword, redisHost, redisPort, constant.Redis0Config)
if err != nil {
log.Error(err.Error())
return
}
comm, err := LoadCommonConfig[specialConfig](rdb, "", "", "")
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)
}
}