workDesktop_test.go 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. package service
  2. import (
  3. "app.yhyue.com/moapp/jybase/redis"
  4. "context"
  5. "fmt"
  6. "log"
  7. "testing"
  8. "time"
  9. "userCenter/entity"
  10. "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. var ins []*pb.WorkDesktopMenuInfoReq
  19. ins = append(ins,
  20. &pb.WorkDesktopMenuInfoReq{
  21. UserId: "61e7820581197c2e50af18df",
  22. AppId: "10000",
  23. Platform: "PC",
  24. Phone: "",
  25. BigMemberOff: true,
  26. InternalTime: 1200,
  27. RedisOutTime: 1200,
  28. },
  29. &pb.WorkDesktopMenuInfoReq{
  30. UserId: "61e7820581197c2e50af18df",
  31. AppId: "10000",
  32. Platform: "PC",
  33. Phone: "",
  34. BigMemberOff: true,
  35. InternalTime: 1200,
  36. RedisOutTime: 1200,
  37. },
  38. &pb.WorkDesktopMenuInfoReq{
  39. UserId: "61e7820581197c2e50af18df",
  40. AppId: "10000",
  41. Platform: "WX",
  42. Phone: "",
  43. BigMemberOff: true,
  44. InternalTime: 1200,
  45. RedisOutTime: 1200,
  46. },
  47. &pb.WorkDesktopMenuInfoReq{
  48. UserId: "61e7820581197c2e50af18df",
  49. AppId: "10000",
  50. Platform: "APP",
  51. Phone: "",
  52. BigMemberOff: true,
  53. InternalTime: 1200,
  54. RedisOutTime: 1200,
  55. },
  56. )
  57. var redisMap = map[string]bool{}
  58. for _, in := range ins {
  59. t.Run("工作桌面菜单树", func(t *testing.T) {
  60. if !redisMap[in.Platform] {
  61. RedisMenuKey := fmt.Sprintf(entity.RedisMenuKey, in.AppId, in.Platform, in.UserId)
  62. redis.Del(entity.RedisCode, RedisMenuKey)
  63. }
  64. res, err := GetWordDesktopMenuTree(in)
  65. log.Println("err:", err, "---res:", res)
  66. })
  67. }
  68. }
  69. // 菜单模式插入
  70. // go test -v -run Test_MenuMode
  71. func Test_MenuMode(t *testing.T) {
  72. var ins []*pb.WorkDesktopComprehensiveReq
  73. ins = append(ins,
  74. &pb.WorkDesktopComprehensiveReq{
  75. UserId: "61e7820581197c2e50af18df",
  76. AppId: "10000",
  77. Platform: "PC",
  78. Phone: "",
  79. ActionMode: "menuMode",
  80. MenuMode: "usable",
  81. MenuIds: "",
  82. BigMemberOff: true,
  83. CommonlySize: 10,
  84. RedisOutTime: 1200,
  85. }, &pb.WorkDesktopComprehensiveReq{
  86. UserId: "61e7820581197c2e50af18df",
  87. AppId: "10000",
  88. Platform: "PC",
  89. Phone: "",
  90. ActionMode: "menuMode",
  91. MenuMode: "allll",
  92. MenuIds: "",
  93. BigMemberOff: true,
  94. CommonlySize: 10,
  95. RedisOutTime: 1200,
  96. }, &pb.WorkDesktopComprehensiveReq{
  97. UserId: "61e7820581197c2e50af18df",
  98. AppId: "10000",
  99. Platform: "PC",
  100. Phone: "",
  101. ActionMode: "menuMode",
  102. MenuMode: "all",
  103. MenuIds: "",
  104. BigMemberOff: true,
  105. CommonlySize: 10,
  106. RedisOutTime: 1200,
  107. },
  108. )
  109. for _, in := range ins {
  110. t.Run("菜单模式插入、异常、更新", func(t *testing.T) {
  111. res := RenewWorkDesktopMenuModeOrCommonly(in)
  112. log.Println("menuModeNew:", res)
  113. })
  114. }
  115. }
  116. //当前工作桌面菜单模式
  117. // go test -v -run Test_WorkMenuMode
  118. func Test_WorkMenuMode(t *testing.T) {
  119. var ins []*pb.WorkDesktopMenuInfoReq
  120. ins = append(ins,
  121. &pb.WorkDesktopMenuInfoReq{
  122. UserId: "61e7820581197c2e50af18df",
  123. AppId: "10000",
  124. Platform: "PC",
  125. Phone: "",
  126. BigMemberOff: true,
  127. InternalTime: 1200,
  128. RedisOutTime: 1200,
  129. }, &pb.WorkDesktopMenuInfoReq{
  130. UserId: "",
  131. AppId: "10000",
  132. Platform: "PC",
  133. Phone: "",
  134. BigMemberOff: true,
  135. InternalTime: 1200,
  136. RedisOutTime: 1200,
  137. },
  138. )
  139. for _, in := range ins {
  140. t.Run("当前工作桌面菜单模式(非正常用户|正常用户)", func(t *testing.T) {
  141. res, err := GetWorkDesktopMenuMode(in)
  142. log.Println("err:", err, "---res:", res)
  143. })
  144. }
  145. }
  146. // 常用功能更新新增
  147. // go test -v -run Test_CommonlyRenewWX
  148. func Test_CommonlyRenewWX(t *testing.T) {
  149. in := &pb.WorkDesktopComprehensiveReq{
  150. UserId: "61e7820581197c2e50af18df",
  151. AppId: "10000",
  152. Platform: "WX",
  153. Phone: "",
  154. ActionMode: "commonlyRenew",
  155. MenuMode: "",
  156. MenuIds: "Q1o=,TF4=,TFw=,TFg=,Q1g=,RV9F,RV9J,RV5B,RV5H,RV5J,TVg=",
  157. }
  158. res := RenewWorkDesktopMenuModeOrCommonly(in)
  159. log.Println("res:", res)
  160. }
  161. // 常用功能更新新增
  162. // go test -v -run Test_CommonlyRenewAPP
  163. func Test_CommonlyRenewAPP(t *testing.T) {
  164. in := &pb.WorkDesktopComprehensiveReq{
  165. UserId: "61e7820581197c2e50af18df",
  166. AppId: "10000",
  167. Platform: "APP",
  168. Phone: "",
  169. ActionMode: "commonlyRenew",
  170. MenuMode: "",
  171. MenuIds: "Q1o=,TF4=,TFw=,TFg=,Q1g=,RV9F,RV9J,RV5B,RV5H,RV5J,TVg=",
  172. }
  173. res := RenewWorkDesktopMenuModeOrCommonly(in)
  174. log.Println("res:", res)
  175. }
  176. // 常用功能更新新增
  177. // go test -v -run Test_CommonlyRenew
  178. func Test_CommonlyRenew(t *testing.T) {
  179. in := &pb.WorkDesktopComprehensiveReq{
  180. UserId: "61e7820581197c2e50af18df",
  181. AppId: "10000",
  182. Platform: "PC",
  183. Phone: "",
  184. ActionMode: "commonlyRenew",
  185. MenuMode: "",
  186. MenuIds: "Q1o=,TF4=,TFw=,TFg=,Q1g=,RV9F,RV9J,RV5B,RV5H,RV5J,TVg=",
  187. }
  188. res := RenewWorkDesktopMenuModeOrCommonly(in)
  189. log.Println("res:", res)
  190. }
  191. // 常用功能列表
  192. // go test -v -run Test_CommonlyList
  193. func Test_CommonlyList(t *testing.T) {
  194. in := &pb.WorkDesktopComprehensiveReq{
  195. UserId: "61e7820581197c2e50af18df",
  196. AppId: "10000",
  197. Platform: "PC",
  198. Phone: "",
  199. ActionMode: "commonlyList",
  200. MenuMode: "",
  201. MenuIds: "",
  202. }
  203. res := RenewWorkDesktopMenuModeOrCommonly(in)
  204. log.Println("res:", res)
  205. } // 常用功能列表
  206. // go test -v -run Test_CommonlyListWX
  207. func Test_CommonlyListWX(t *testing.T) {
  208. in := &pb.WorkDesktopComprehensiveReq{
  209. UserId: "61e7820581197c2e50af18df",
  210. AppId: "10000",
  211. Platform: "WX",
  212. Phone: "",
  213. ActionMode: "commonlyList",
  214. MenuMode: "",
  215. MenuIds: "",
  216. }
  217. res := RenewWorkDesktopMenuModeOrCommonly(in)
  218. log.Println("res:", res)
  219. } // 常用功能列表
  220. // go test -v -run Test_CommonlyListAPP
  221. func Test_CommonlyListAPP(t *testing.T) {
  222. in := &pb.WorkDesktopComprehensiveReq{
  223. UserId: "61e7820581197c2e50af18df",
  224. AppId: "10000",
  225. Platform: "APP",
  226. Phone: "",
  227. ActionMode: "commonlyList",
  228. MenuMode: "",
  229. MenuIds: "",
  230. }
  231. res := RenewWorkDesktopMenuModeOrCommonly(in)
  232. log.Println("res:", res)
  233. }
  234. // 常用功能更新清空
  235. // go test -v -run Test_CommonlyRenew
  236. func Test_CommonlyClear(t *testing.T) {
  237. in := &pb.WorkDesktopComprehensiveReq{
  238. UserId: "61e7820581197c2e50af18df",
  239. AppId: "10000",
  240. Platform: "PC",
  241. Phone: "",
  242. ActionMode: "commonlyRenew",
  243. MenuMode: "",
  244. MenuIds: "",
  245. }
  246. res := RenewWorkDesktopMenuModeOrCommonly(in)
  247. log.Println("res:", res)
  248. }