上传hero_test 测试脚本
This commit is contained in:
parent
928f2ccc11
commit
3db2d0dc46
@ -1,12 +1,19 @@
|
||||
package hero
|
||||
package hero_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego"
|
||||
"go_dreamfactory/lego/base/rpcx"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/modules/equipment"
|
||||
"go_dreamfactory/modules/hero"
|
||||
"go_dreamfactory/modules/items"
|
||||
"go_dreamfactory/modules/task"
|
||||
"go_dreamfactory/modules/user"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/services"
|
||||
"go_dreamfactory/sys/cache"
|
||||
"go_dreamfactory/sys/configure"
|
||||
@ -14,12 +21,14 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/golang/protobuf/ptypes"
|
||||
)
|
||||
|
||||
var service core.IService
|
||||
var s_gateComp comm.ISC_GateRouteComp = services.NewGateRouteComp()
|
||||
|
||||
var module = new(Hero)
|
||||
var module = new(hero.Hero)
|
||||
|
||||
type TestService struct {
|
||||
rpcx.RPCXService
|
||||
@ -34,7 +43,7 @@ func newService(ops ...rpcx.Option) core.IService {
|
||||
//初始化相关系统
|
||||
func (this *TestService) InitSys() {
|
||||
this.RPCXService.InitSys()
|
||||
if err := cache.OnInit(this.GetSettings().Sys["cache"]); err != nil {
|
||||
if err := cache.OnInit(this.GetSettings().Sys["cache"], cache.Set_Redis_Addr([]string{"10.0.0.9:10011"}), cache.Set_Redis_Password("li13451234"), cache.Set_Redis_DB(1)); err != nil {
|
||||
panic(fmt.Sprintf("init sys.cache err: %s", err.Error()))
|
||||
} else {
|
||||
log.Infof("init sys.cache success!")
|
||||
@ -44,7 +53,7 @@ func (this *TestService) InitSys() {
|
||||
} else {
|
||||
log.Infof("init sys.db success!")
|
||||
}
|
||||
if err := configure.OnInit(this.GetSettings().Sys["configure"], configure.SetConfigPath("E:\\projects\\workspace\\go_dreamfactory\\bin\\json")); err != nil {
|
||||
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!")
|
||||
@ -61,40 +70,18 @@ func TestMain(m *testing.M) {
|
||||
go func() {
|
||||
lego.Run(service, //运行模块
|
||||
module,
|
||||
//
|
||||
items.NewModule(),
|
||||
user.NewModule(),
|
||||
equipment.NewModule(),
|
||||
task.NewModule(),
|
||||
)
|
||||
}()
|
||||
time.Sleep(time.Second * 2)
|
||||
defer os.Exit(m.Run())
|
||||
}
|
||||
|
||||
//创建一个英雄s
|
||||
func TestCreateOneHero(t *testing.T) {
|
||||
err := module.modelHero.createOneHero("u1", 25001, true)
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
//获取玩家英雄
|
||||
func TestGetOneHero(t *testing.T) {
|
||||
d := module.modelHero.getOneHero("u1", "62b534bebf4745d4117acabe")
|
||||
fmt.Printf("%v", d)
|
||||
}
|
||||
|
||||
func TestPropertyCompute(t *testing.T) {
|
||||
m := module.modelHero.PropertyCompute("u1", "62b534bebf4745d4117acabe")
|
||||
fmt.Println(m)
|
||||
}
|
||||
|
||||
func TestHeroList(t *testing.T) {
|
||||
heroes := module.modelHero.getHeroList("u1")
|
||||
fmt.Printf("%v", heroes)
|
||||
}
|
||||
|
||||
func TestModify(t *testing.T) {
|
||||
data := map[string]interface{}{
|
||||
"lv": 2,
|
||||
"exp": 1000,
|
||||
}
|
||||
err := module.modelHero.modifyHeroData("u1", "62b534bebf4745d4117acabe", data)
|
||||
fmt.Printf("%v ", err)
|
||||
func Test_Modules(t *testing.T) {
|
||||
data, _ := ptypes.MarshalAny(&pb.HeroListReq{})
|
||||
reply := &pb.RPCMessageReply{}
|
||||
s_gateComp.ReceiveMsg(context.Background(), &pb.AgentMessage{UserId: "0_62c79d66acc7aa239b07c21e", MainType: "hero", SubType: "list", Message: data}, reply)
|
||||
log.Debugf("reply:%v", reply)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user