workDesktop_test.go 7.0 KB

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