测试job1

This commit is contained in:
zhaocy 2022-06-30 19:53:30 +08:00
parent 40dfd55866
commit 1ed01cb9b6
8 changed files with 27 additions and 11 deletions

View File

@ -8,7 +8,7 @@ import (
var ( var (
//friend //friend
friendBuilders = []*builder{ friendBuilders = []*testCase{
{ {
//list //list
mainType: string(comm.ModuleFriend), mainType: string(comm.ModuleFriend),

View File

@ -11,7 +11,7 @@ import (
var ( var (
//hero //hero
heroBuilders = []*builder{ heroBuilders = []*testCase{
{ {
desc: "英雄列表", desc: "英雄列表",
mainType: string(comm.ModuleHero), mainType: string(comm.ModuleHero),

16
cmd/robot/job.go Normal file
View File

@ -0,0 +1,16 @@
package robot
type CaseNode struct {
caseName testCase //用例名
next *CaseNode //测试用例
}
type LinkCase struct {
head *CaseNode
}
func NewLinkCase() *LinkCase {
return &LinkCase{}
}

View File

@ -35,7 +35,7 @@ func (r *Robot) BuildSecStr() string {
//处理登录请求 //处理登录请求
func (r *Robot) AccountLogin() { func (r *Robot) AccountLogin() {
log.Printf("区服:[%d] 账号:[%s] login...", r.opts.ServerId, r.opts.Account) log.Printf("区服:[%d] 账号:[%s] login...", r.opts.ServerId, r.opts.Account)
builders := []*builder{ builders := []*testCase{
{ {
mainType: string(comm.ModuleUser), mainType: string(comm.ModuleUser),
subType: user.UserSubTypeLogin, subType: user.UserSubTypeLogin,

View File

@ -5,7 +5,7 @@ import (
"go_dreamfactory/pb" "go_dreamfactory/pb"
) )
var notify_builders = []*builder{ var notify_builders = []*testCase{
{ {
//create //create
mainType: comm.MainTypeNotify, mainType: comm.MainTypeNotify,

View File

@ -6,7 +6,7 @@ import (
) )
//申明测试接口及请求和响应参数 //申明测试接口及请求和响应参数
var pack_builders = []*builder{ var pack_builders = []*testCase{
{ {
//create //create
mainType: string(comm.ModulePack), mainType: string(comm.ModulePack),

View File

@ -20,7 +20,7 @@ type Robot struct {
ws *websocket.Conn ws *websocket.Conn
opts *Options opts *Options
user *pb.DBUser user *pb.DBUser
builders []*builder builders []*testCase
} }
func NewRobot(opts *Options) *Robot { func NewRobot(opts *Options) *Robot {
@ -67,7 +67,7 @@ func (r *Robot) Run() {
select {} select {}
} }
type builder struct { type testCase struct {
desc string desc string
mainType string mainType string
subType string subType string
@ -79,7 +79,7 @@ type builder struct {
print func(rsp proto.Message) print func(rsp proto.Message)
} }
func (r *Robot) addBuilders(builders []*builder) { func (r *Robot) addBuilders(builders []*testCase) {
for _, b := range builders { for _, b := range builders {
if b.enabled { if b.enabled {
r.builders = append(r.builders, b) r.builders = append(r.builders, b)
@ -199,7 +199,7 @@ func (r *Robot) AccountRegister(account string, sid int32) {
fmt.Printf("account:%s 注册成功", regRsp.Account) fmt.Printf("account:%s 注册成功", regRsp.Account)
//登录 //登录
var user_builders = []*builder{ var user_builders = []*testCase{
{ {
desc: "登录", desc: "登录",
mainType: "user", mainType: "user",
@ -218,7 +218,7 @@ func (r *Robot) AccountRegister(account string, sid int32) {
} }
//打印响应 //打印响应
func printReply(msg *pb.UserMessage, builder *builder) { func printReply(msg *pb.UserMessage, builder *testCase) {
if m, ok := builder.rsp.(*pb.NotifyErrorNotifyPush); ok { if m, ok := builder.rsp.(*pb.NotifyErrorNotifyPush); ok {
var tt time.Duration var tt time.Duration
if builder.start.IsZero() { if builder.start.IsZero() {

View File

@ -7,7 +7,7 @@ import (
) )
//申明测试接口及请求和响应参数 //申明测试接口及请求和响应参数
var user_builders = []*builder{ var user_builders = []*testCase{
{ {
//create //create
desc: "创角", desc: "创角",