go_dreamfactory/modules/entertainment/xxl_test.go

101 lines
2.4 KiB
Go

package entertainment_test
import (
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/lego"
"go_dreamfactory/lego/base/rpcx"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules/entertainment"
"go_dreamfactory/modules/equipment"
"go_dreamfactory/modules/items"
"go_dreamfactory/modules/user"
"go_dreamfactory/pb"
"go_dreamfactory/services"
"go_dreamfactory/sys/configure"
"go_dreamfactory/sys/db"
"reflect"
"strings"
"testing"
"time"
flag "github.com/spf13/pflag"
)
var service core.IService
var s_gateComp comm.ISC_GateRouteComp = services.NewGateRouteComp()
type TestService struct {
rpcx.RPCXService
}
func newService(ops ...rpcx.Option) core.IService {
s := new(TestService)
s.Configure(ops...)
return s
}
//初始化相关系统
func (this *TestService) InitSys() {
this.RPCXService.InitSys()
// if err := log.OnInit(); err != nil {
// panic(fmt.Sprintf("Sys log Init err:%v", err))
// } else {
// log.Infof("Sys log Init success !")
// }
if err := db.OnInit(this.GetSettings().Sys["db"]); err != nil {
panic(fmt.Sprintf("init sys.db err: %s", err.Error()))
} else {
log.Infof("init sys.db success!")
}
if err := configure.OnInit(this.GetSettings().Sys["configure"], configure.SetConfigPath("F:/work/go/go_dreamfactory/bin/json")); err != nil {
panic(fmt.Sprintf("init sys.configure err: %s", err.Error()))
} else {
log.Infof("init sys.configure success!")
}
}
func Test_Main(t *testing.T) {
service = newService(
rpcx.SetConfPath("../../bin/conf/worker_1.yaml"),
)
service.OnInstallComp( //装备组件
s_gateComp, //此服务需要接受用户的消息 需要装备网关组件
)
go func() {
lego.Run(service, //运行模块
entertainment.NewModule(),
items.NewModule(),
user.NewModule(),
equipment.NewModule(),
)
}()
time.Sleep(time.Second * 2)
//equipment.CloneEquipment()
}
func GetMap() map[int32]int32 {
return nil
}
func copyPoint(m *pb.DBHero) *pb.DBHero {
vt := reflect.TypeOf(m).Elem()
fmt.Println(vt)
newoby := reflect.New(vt)
newoby.Elem().Set(reflect.ValueOf(m).Elem())
newoby.Interface().(*pb.DBHero).Lv = 1111
return newoby.Interface().(*pb.DBHero)
}
func wordSepNormalizeFunc(f *flag.FlagSet, name string) flag.NormalizedName {
from := []string{"-", "_"}
to := "."
for _, sep := range from {
name = strings.Replace(name, sep, to, -1)
}
return flag.NormalizedName(name)
}