go_dreamfactory/cmd/robot/friend.go
2022-08-18 18:52:22 +08:00

106 lines
2.7 KiB
Go

package robot
import (
"go_dreamfactory/comm"
"go_dreamfactory/modules/friend"
"go_dreamfactory/pb"
"google.golang.org/protobuf/proto"
)
var (
//friend
friendBuilders = []*TestCase{
{
desc: "好友列表",
mainType: string(comm.ModuleFriend),
subType: friend.FriendSubTypeList,
req: &pb.FriendListReq{},
rsp: &pb.FriendListResp{},
// enabled: true,
}, {
desc: "黑名单列表",
mainType: string(comm.ModuleFriend),
subType: friend.FriendSubTypeBlacklist,
req: &pb.FriendBlackListReq{},
rsp: &pb.FriendBlackListResp{},
// enabled: true,
}, {
//search
mainType: string(comm.ModuleFriend),
subType: friend.FriendSubTypeSearch,
req: &pb.FriendSearchReq{
NickName: "乐谷745", //设置测试参数
},
rsp: &pb.FriendSearchResp{},
// enabled: true,
}, {
desc: "好友申请",
mainType: string(comm.ModuleFriend),
subType: friend.FriendSubTypeApply,
req: &pb.FriendApplyReq{
FriendId: "0_62ccd236e799cee5e7c97930",
},
rsp: &pb.FriendApplyResp{},
// enabled: true,
}, {
desc: "申请列表",
mainType: string(comm.ModuleFriend),
subType: friend.FriendSubTypeApplyList,
req: &pb.FriendApplyListReq{},
rsp: &pb.FriendApplyListResp{},
// enabled: true,
}, {
desc: "同意",
mainType: string(comm.ModuleFriend),
subType: friend.FriendSubTypeAgree,
req: &pb.FriendAgreeReq{
FriendIds: []string{"0_62c28ab569b7d416cf9eb8c7"},
},
rsp: &pb.FriendAgreeResp{},
// enabled: true,
}, {
desc: "拒绝",
mainType: string(comm.ModuleFriend),
subType: friend.FriendSubTypeRefuse,
req: &pb.FriendRefuseReq{
FriendIds: []string{"0_62c28bcb69b7d416cf9eb8c9"},
},
rsp: &pb.FriendRefuseResp{},
// enabled: true,
}, {
desc: "添加黑名单",
mainType: string(comm.ModuleFriend),
subType: friend.FriendSubTypeAddBlack,
req: &pb.FriendAddBlackReq{
FriendId: "0_62ccd236e799cee5e7c97930",
},
rsp: &pb.FriendAddBlackResp{},
// enabled: true,
next: func(robot *Robot, rsp proto.Message) {
tcs := []*TestCase{}
if r, ok := rsp.(*pb.FriendAddBlackResp); ok {
tc := &TestCase{
desc: "删除黑名单",
mainType: string(comm.ModuleFriend),
subType: friend.FriendSubTypeDelBlack,
req: &pb.FriendDelBlackReq{
FriendId: r.FriendId,
},
rsp: &pb.FriendDelBlackResp{},
enabled: true,
}
tcs = append(tcs, tc)
robot.addBuilders(tcs) //这里一定要调用此方法才会发送请求
}
},
},
}
)
//声明加入到构建器
func (r *Robot) RunFriend() {
r.addBuilders(friendBuilders)
}