机器人job2
This commit is contained in:
parent
1ed01cb9b6
commit
435d901936
@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
//friend
|
//friend
|
||||||
friendBuilders = []*testCase{
|
friendBuilders = []*TestCase{
|
||||||
{
|
{
|
||||||
//list
|
//list
|
||||||
mainType: string(comm.ModuleFriend),
|
mainType: string(comm.ModuleFriend),
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
//hero
|
//hero
|
||||||
heroBuilders = []*testCase{
|
heroBuilders = []*TestCase{
|
||||||
{
|
{
|
||||||
desc: "英雄列表",
|
desc: "英雄列表",
|
||||||
mainType: string(comm.ModuleHero),
|
mainType: string(comm.ModuleHero),
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package robot
|
package robot
|
||||||
|
|
||||||
type CaseNode struct {
|
type CaseNode struct {
|
||||||
caseName testCase //用例名
|
testCase TestCase //用例名
|
||||||
next *CaseNode //测试用例
|
next *CaseNode //测试用例
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -13,4 +13,14 @@ func NewLinkCase() *LinkCase {
|
|||||||
return &LinkCase{}
|
return &LinkCase{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *LinkCase) isEmpty() bool {
|
||||||
|
return this.head == nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *LinkCase) append(testCase *TestCase) {
|
||||||
|
newNode := &CaseNode{testCase: *testCase}
|
||||||
|
if this.isEmpty() {
|
||||||
|
this.head = newNode
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -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 := []*testCase{
|
builders := []*TestCase{
|
||||||
{
|
{
|
||||||
mainType: string(comm.ModuleUser),
|
mainType: string(comm.ModuleUser),
|
||||||
subType: user.UserSubTypeLogin,
|
subType: user.UserSubTypeLogin,
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
)
|
)
|
||||||
|
|
||||||
var notify_builders = []*testCase{
|
var notify_builders = []*TestCase{
|
||||||
{
|
{
|
||||||
//create
|
//create
|
||||||
mainType: comm.MainTypeNotify,
|
mainType: comm.MainTypeNotify,
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
//申明测试接口及请求和响应参数
|
//申明测试接口及请求和响应参数
|
||||||
var pack_builders = []*testCase{
|
var pack_builders = []*TestCase{
|
||||||
{
|
{
|
||||||
//create
|
//create
|
||||||
mainType: string(comm.ModulePack),
|
mainType: string(comm.ModulePack),
|
||||||
|
@ -20,7 +20,7 @@ type Robot struct {
|
|||||||
ws *websocket.Conn
|
ws *websocket.Conn
|
||||||
opts *Options
|
opts *Options
|
||||||
user *pb.DBUser
|
user *pb.DBUser
|
||||||
builders []*testCase
|
builders []*TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRobot(opts *Options) *Robot {
|
func NewRobot(opts *Options) *Robot {
|
||||||
@ -67,7 +67,7 @@ func (r *Robot) Run() {
|
|||||||
select {}
|
select {}
|
||||||
}
|
}
|
||||||
|
|
||||||
type testCase struct {
|
type TestCase struct {
|
||||||
desc string
|
desc string
|
||||||
mainType string
|
mainType string
|
||||||
subType string
|
subType string
|
||||||
@ -79,7 +79,7 @@ type testCase struct {
|
|||||||
print func(rsp proto.Message)
|
print func(rsp proto.Message)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Robot) addBuilders(builders []*testCase) {
|
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 = []*testCase{
|
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 *testCase) {
|
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() {
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
//申明测试接口及请求和响应参数
|
//申明测试接口及请求和响应参数
|
||||||
var user_builders = []*testCase{
|
var user_builders = []*TestCase{
|
||||||
{
|
{
|
||||||
//create
|
//create
|
||||||
desc: "创角",
|
desc: "创角",
|
||||||
|
Loading…
Reference in New Issue
Block a user