package service import ( MC "app.yhyue.com/moapp/jybase/common" "context" "fmt" "log" "testing" "time" "app.yhyue.com/moapp/jybase/redis" "bp.jydev.jianyu360.cn/BaseService/userCenter/entity" "bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/pb" ) var ( ctx, _ = context.WithTimeout(context.Background(), 2*time.Second) ) // 工作桌面菜单树 无缓存 // go test -run=Test_WorkDesktopMenuTree func Test_WorkDesktopMenuTree(t *testing.T) { tests := []struct { name string //备注(表名) args *pb.WorkDesktopMenuInfoReq //参数 want string //期望值 }{ //类似表格数据 { name: "PC端无缓存菜单树接口", args: &pb.WorkDesktopMenuInfoReq{ UserId: "61e7820581197c2e50af18df", AppId: "10000", Platform: "PC", }, want: "", }, { name: "PC端有缓存菜单树接口", args: &pb.WorkDesktopMenuInfoReq{ UserId: "61e7820581197c2e50af18df", AppId: "10000", Platform: "PC", }, want: "", }, { name: "WX端无缓存菜单树接口", args: &pb.WorkDesktopMenuInfoReq{ UserId: "61e7820581197c2e50af18df", AppId: "10000", Platform: "WX", }, want: "", }, { name: "APP端无缓存菜单树接口", args: &pb.WorkDesktopMenuInfoReq{ UserId: "61e7820581197c2e50af18df", AppId: "10000", Platform: "APP", }, want: "", }, } for _, in := range tests { t.Run(in.name, func(t *testing.T) { RedisMenuKey := fmt.Sprintf(entity.RedisMenuKey, in.args.AppId, in.args.Platform, MC.If(in.args.PositionId != "", in.args.PositionId, in.args.UserId).(string)) redis.Del(entity.RedisCode, RedisMenuKey) res, err := GetWordDesktopMenuTree(in.args) if len(res) == 0 || err != nil { log.Println(in.args.Platform, "异常:") } }) } } // 菜单模式插入 // go test -v -run Test_MenuMode func Test_MenuMode(t *testing.T) { var tests = []struct { name string args *pb.WorkDesktopComprehensiveReq want string }{ { name: "工作桌面菜单模式插入", args: &pb.WorkDesktopComprehensiveReq{ UserId: "61e7820581197c2e50af18df", NewUserId: "61e7820581197c2e50af18df", AppId: "10000", Platform: "PC", ActionMode: "menuMode", MenuMode: "usable", }, want: "", }, { name: "工作桌面菜单模式异常", args: &pb.WorkDesktopComprehensiveReq{ UserId: "61e7820581197c2e50af18df", NewUserId: "61e7820581197c2e50af18df", AppId: "10000", Platform: "PC", ActionMode: "menuMode", MenuMode: "allll", }, want: "", }, { name: "工作桌面菜单模式更新", args: &pb.WorkDesktopComprehensiveReq{ UserId: "61e7820581197c2e50af18df", NewUserId: "61e7820581197c2e50af18df", AppId: "10000", Platform: "PC", ActionMode: "menuMode", MenuMode: "all", }, want: "", }, } for _, in := range tests { t.Run(in.name, func(t *testing.T) { res := RenewWorkDesktopMenuModeOrCommonly(in.args) log.Println("menuModeNew:", res, in.want) }) } } // 当前工作桌面菜单模式 // go test -v -run Test_WorkMenuMode func Test_WorkMenuMode(t *testing.T) { var tests = []struct { name string args *pb.WorkDesktopMenuInfoReq want string }{ { name: "获取当前工作桌面菜单模式", args: &pb.WorkDesktopMenuInfoReq{ UserId: "61e7820581197c2e50af18df", NewUserId: "61e7820581197c2e50af18df", AppId: "10000", Platform: "PC", }, want: "", }, { name: "异常获取当前工作桌面菜单模式", args: &pb.WorkDesktopMenuInfoReq{ UserId: "", NewUserId: "", AppId: "10000", Platform: "PC", }, want: "", }, } for _, in := range tests { t.Run(in.name, func(t *testing.T) { res, err := GetWorkDesktopMenuMode(in.args) log.Println("err:", err, "---res:", res, in.want) }) } } // 常用功能更新新增 // go test -v -run Test_CommonlyRenewWX func Test_CommonlyRenewWX(t *testing.T) { in := &pb.WorkDesktopComprehensiveReq{ UserId: "61e7820581197c2e50af18df", NewUserId: "61e7820581197c2e50af18df", AppId: "10000", Platform: "WX", Phone: "", ActionMode: "commonlyRenew", MenuMode: "", MenuIds: "Q1o=,TF4=,TFw=,TFg=,Q1g=,RV9F,RV9J,RV5B,RV5H,RV5J,TVg=", } res := RenewWorkDesktopMenuModeOrCommonly(in) log.Println("res:", res) } // 常用功能更新新增 // go test -v -run Test_CommonlyRenewAPP func Test_CommonlyRenewAPP(t *testing.T) { in := &pb.WorkDesktopComprehensiveReq{ UserId: "61e7820581197c2e50af18df", NewUserId: "61e7820581197c2e50af18df", AppId: "10000", Platform: "APP", Phone: "", ActionMode: "commonlyRenew", MenuMode: "", MenuIds: "Q1o=,TF4=,TFw=,TFg=,Q1g=,RV9F,RV9J,RV5B,RV5H,RV5J,TVg=", } res := RenewWorkDesktopMenuModeOrCommonly(in) log.Println("res:", res) } // 常用功能更新新增 // go test -v -run Test_CommonlyRenew func Test_CommonlyRenew(t *testing.T) { in := &pb.WorkDesktopComprehensiveReq{ UserId: "61e7820581197c2e50af18df", NewUserId: "61e7820581197c2e50af18df", AppId: "10000", Platform: "PC", Phone: "", ActionMode: "commonlyRenew", MenuMode: "", MenuIds: "Q1o=,TF4=,TFw=,TFg=,Q1g=,RV9F,RV9J,RV5B,RV5H,RV5J,TVg=", } res := RenewWorkDesktopMenuModeOrCommonly(in) log.Println("res:", res) } // 常用功能列表 // go test -v -run Test_CommonlyList func Test_CommonlyList(t *testing.T) { in := &pb.WorkDesktopComprehensiveReq{ UserId: "61e7820581197c2e50af18df", NewUserId: "61e7820581197c2e50af18df", AppId: "10000", Platform: "PC", Phone: "", ActionMode: "commonlyList", MenuMode: "", MenuIds: "", } res := RenewWorkDesktopMenuModeOrCommonly(in) log.Println("res:", res) } // 常用功能列表 // go test -v -run Test_CommonlyListWX func Test_CommonlyListWX(t *testing.T) { in := &pb.WorkDesktopComprehensiveReq{ UserId: "61e7820581197c2e50af18df", NewUserId: "61e7820581197c2e50af18df", AppId: "10000", Platform: "WX", Phone: "", ActionMode: "commonlyList", MenuMode: "", MenuIds: "", } res := RenewWorkDesktopMenuModeOrCommonly(in) log.Println("res:", res) } // 常用功能列表 // go test -v -run Test_CommonlyListAPP func Test_CommonlyListAPP(t *testing.T) { in := &pb.WorkDesktopComprehensiveReq{ UserId: "61e7820581197c2e50af18df", NewUserId: "61e7820581197c2e50af18df", AppId: "10000", Platform: "APP", Phone: "", ActionMode: "commonlyList", MenuMode: "", MenuIds: "", } res := RenewWorkDesktopMenuModeOrCommonly(in) log.Println("res:", res) } // 常用功能更新清空 // go test -v -run Test_CommonlyRenew func Test_CommonlyClear(t *testing.T) { in := &pb.WorkDesktopComprehensiveReq{ UserId: "61e7820581197c2e50af18df", NewUserId: "61e7820581197c2e50af18df", AppId: "10000", Platform: "PC", Phone: "", ActionMode: "commonlyRenew", MenuMode: "", MenuIds: "", } res := RenewWorkDesktopMenuModeOrCommonly(in) log.Println("res:", res) }