workDesktop_test.go 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. package service
  2. import (
  3. MC "app.yhyue.com/moapp/jybase/common"
  4. "context"
  5. "fmt"
  6. "log"
  7. "testing"
  8. "time"
  9. "app.yhyue.com/moapp/jybase/redis"
  10. "bp.jydev.jianyu360.cn/BaseService/userCenter/entity"
  11. "bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/pb"
  12. )
  13. var (
  14. ctx, _ = context.WithTimeout(context.Background(), 2*time.Second)
  15. )
  16. // 工作桌面菜单树 无缓存
  17. // go test -run=Test_WorkDesktopMenuTree
  18. func Test_WorkDesktopMenuTree(t *testing.T) {
  19. tests := []struct {
  20. name string //备注(表名)
  21. args *pb.WorkDesktopMenuInfoReq //参数
  22. want string //期望值
  23. }{
  24. //类似表格数据
  25. {
  26. name: "PC端无缓存菜单树接口",
  27. args: &pb.WorkDesktopMenuInfoReq{
  28. UserId: "61e7820581197c2e50af18df",
  29. AppId: "10000",
  30. Platform: "PC",
  31. },
  32. want: "",
  33. },
  34. {
  35. name: "PC端有缓存菜单树接口",
  36. args: &pb.WorkDesktopMenuInfoReq{
  37. UserId: "61e7820581197c2e50af18df",
  38. AppId: "10000",
  39. Platform: "PC",
  40. },
  41. want: "",
  42. },
  43. {
  44. name: "WX端无缓存菜单树接口",
  45. args: &pb.WorkDesktopMenuInfoReq{
  46. UserId: "61e7820581197c2e50af18df",
  47. AppId: "10000",
  48. Platform: "WX",
  49. },
  50. want: "",
  51. },
  52. {
  53. name: "APP端无缓存菜单树接口",
  54. args: &pb.WorkDesktopMenuInfoReq{
  55. UserId: "61e7820581197c2e50af18df",
  56. AppId: "10000",
  57. Platform: "APP",
  58. },
  59. want: "",
  60. },
  61. }
  62. for _, in := range tests {
  63. t.Run(in.name, func(t *testing.T) {
  64. RedisMenuKey := fmt.Sprintf(entity.RedisMenuKey, in.args.AppId, in.args.Platform, MC.If(in.args.PositionId != "", in.args.PositionId, in.args.UserId).(string))
  65. redis.Del(entity.RedisCode, RedisMenuKey)
  66. res, err := GetWordDesktopMenuTree(in.args)
  67. if len(res) == 0 || err != nil {
  68. log.Println(in.args.Platform, "异常:")
  69. }
  70. })
  71. }
  72. }
  73. // 菜单模式插入
  74. // go test -v -run Test_MenuMode
  75. func Test_MenuMode(t *testing.T) {
  76. var tests = []struct {
  77. name string
  78. args *pb.WorkDesktopComprehensiveReq
  79. want string
  80. }{
  81. {
  82. name: "工作桌面菜单模式插入",
  83. args: &pb.WorkDesktopComprehensiveReq{
  84. UserId: "61e7820581197c2e50af18df",
  85. NewUserId: "61e7820581197c2e50af18df",
  86. AppId: "10000",
  87. Platform: "PC",
  88. ActionMode: "menuMode",
  89. MenuMode: "usable",
  90. },
  91. want: "",
  92. },
  93. {
  94. name: "工作桌面菜单模式异常",
  95. args: &pb.WorkDesktopComprehensiveReq{
  96. UserId: "61e7820581197c2e50af18df",
  97. NewUserId: "61e7820581197c2e50af18df",
  98. AppId: "10000",
  99. Platform: "PC",
  100. ActionMode: "menuMode",
  101. MenuMode: "allll",
  102. },
  103. want: "",
  104. },
  105. {
  106. name: "工作桌面菜单模式更新",
  107. args: &pb.WorkDesktopComprehensiveReq{
  108. UserId: "61e7820581197c2e50af18df",
  109. NewUserId: "61e7820581197c2e50af18df",
  110. AppId: "10000",
  111. Platform: "PC",
  112. ActionMode: "menuMode",
  113. MenuMode: "all",
  114. },
  115. want: "",
  116. },
  117. }
  118. for _, in := range tests {
  119. t.Run(in.name, func(t *testing.T) {
  120. res := RenewWorkDesktopMenuModeOrCommonly(in.args)
  121. log.Println("menuModeNew:", res, in.want)
  122. })
  123. }
  124. }
  125. // 当前工作桌面菜单模式
  126. // go test -v -run Test_WorkMenuMode
  127. func Test_WorkMenuMode(t *testing.T) {
  128. var tests = []struct {
  129. name string
  130. args *pb.WorkDesktopMenuInfoReq
  131. want string
  132. }{
  133. {
  134. name: "获取当前工作桌面菜单模式",
  135. args: &pb.WorkDesktopMenuInfoReq{
  136. UserId: "61e7820581197c2e50af18df",
  137. NewUserId: "61e7820581197c2e50af18df",
  138. AppId: "10000",
  139. Platform: "PC",
  140. },
  141. want: "",
  142. },
  143. {
  144. name: "异常获取当前工作桌面菜单模式",
  145. args: &pb.WorkDesktopMenuInfoReq{
  146. UserId: "",
  147. NewUserId: "",
  148. AppId: "10000",
  149. Platform: "PC",
  150. },
  151. want: "",
  152. },
  153. }
  154. for _, in := range tests {
  155. t.Run(in.name, func(t *testing.T) {
  156. res, err := GetWorkDesktopMenuMode(in.args)
  157. log.Println("err:", err, "---res:", res, in.want)
  158. })
  159. }
  160. }
  161. // 常用功能更新新增
  162. // go test -v -run Test_CommonlyRenewWX
  163. func Test_CommonlyRenewWX(t *testing.T) {
  164. in := &pb.WorkDesktopComprehensiveReq{
  165. UserId: "61e7820581197c2e50af18df",
  166. NewUserId: "61e7820581197c2e50af18df",
  167. AppId: "10000",
  168. Platform: "WX",
  169. Phone: "",
  170. ActionMode: "commonlyRenew",
  171. MenuMode: "",
  172. MenuIds: "Q1o=,TF4=,TFw=,TFg=,Q1g=,RV9F,RV9J,RV5B,RV5H,RV5J,TVg=",
  173. }
  174. res := RenewWorkDesktopMenuModeOrCommonly(in)
  175. log.Println("res:", res)
  176. }
  177. // 常用功能更新新增
  178. // go test -v -run Test_CommonlyRenewAPP
  179. func Test_CommonlyRenewAPP(t *testing.T) {
  180. in := &pb.WorkDesktopComprehensiveReq{
  181. UserId: "61e7820581197c2e50af18df",
  182. NewUserId: "61e7820581197c2e50af18df",
  183. AppId: "10000",
  184. Platform: "APP",
  185. Phone: "",
  186. ActionMode: "commonlyRenew",
  187. MenuMode: "",
  188. MenuIds: "Q1o=,TF4=,TFw=,TFg=,Q1g=,RV9F,RV9J,RV5B,RV5H,RV5J,TVg=",
  189. }
  190. res := RenewWorkDesktopMenuModeOrCommonly(in)
  191. log.Println("res:", res)
  192. }
  193. // 常用功能更新新增
  194. // go test -v -run Test_CommonlyRenew
  195. func Test_CommonlyRenew(t *testing.T) {
  196. in := &pb.WorkDesktopComprehensiveReq{
  197. UserId: "61e7820581197c2e50af18df",
  198. NewUserId: "61e7820581197c2e50af18df",
  199. AppId: "10000",
  200. Platform: "PC",
  201. Phone: "",
  202. ActionMode: "commonlyRenew",
  203. MenuMode: "",
  204. MenuIds: "Q1o=,TF4=,TFw=,TFg=,Q1g=,RV9F,RV9J,RV5B,RV5H,RV5J,TVg=",
  205. }
  206. res := RenewWorkDesktopMenuModeOrCommonly(in)
  207. log.Println("res:", res)
  208. }
  209. // 常用功能列表
  210. // go test -v -run Test_CommonlyList
  211. func Test_CommonlyList(t *testing.T) {
  212. in := &pb.WorkDesktopComprehensiveReq{
  213. UserId: "61e7820581197c2e50af18df",
  214. NewUserId: "61e7820581197c2e50af18df",
  215. AppId: "10000",
  216. Platform: "PC",
  217. Phone: "",
  218. ActionMode: "commonlyList",
  219. MenuMode: "",
  220. MenuIds: "",
  221. }
  222. res := RenewWorkDesktopMenuModeOrCommonly(in)
  223. log.Println("res:", res)
  224. } // 常用功能列表
  225. // go test -v -run Test_CommonlyListWX
  226. func Test_CommonlyListWX(t *testing.T) {
  227. in := &pb.WorkDesktopComprehensiveReq{
  228. UserId: "61e7820581197c2e50af18df",
  229. NewUserId: "61e7820581197c2e50af18df",
  230. AppId: "10000",
  231. Platform: "WX",
  232. Phone: "",
  233. ActionMode: "commonlyList",
  234. MenuMode: "",
  235. MenuIds: "",
  236. }
  237. res := RenewWorkDesktopMenuModeOrCommonly(in)
  238. log.Println("res:", res)
  239. } // 常用功能列表
  240. // go test -v -run Test_CommonlyListAPP
  241. func Test_CommonlyListAPP(t *testing.T) {
  242. in := &pb.WorkDesktopComprehensiveReq{
  243. UserId: "61e7820581197c2e50af18df",
  244. NewUserId: "61e7820581197c2e50af18df",
  245. AppId: "10000",
  246. Platform: "APP",
  247. Phone: "",
  248. ActionMode: "commonlyList",
  249. MenuMode: "",
  250. MenuIds: "",
  251. }
  252. res := RenewWorkDesktopMenuModeOrCommonly(in)
  253. log.Println("res:", res)
  254. }
  255. // 常用功能更新清空
  256. // go test -v -run Test_CommonlyRenew
  257. func Test_CommonlyClear(t *testing.T) {
  258. in := &pb.WorkDesktopComprehensiveReq{
  259. UserId: "61e7820581197c2e50af18df",
  260. NewUserId: "61e7820581197c2e50af18df",
  261. AppId: "10000",
  262. Platform: "PC",
  263. Phone: "",
  264. ActionMode: "commonlyRenew",
  265. MenuMode: "",
  266. MenuIds: "",
  267. }
  268. res := RenewWorkDesktopMenuModeOrCommonly(in)
  269. log.Println("res:", res)
  270. }