service_test.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. package service
  2. import (
  3. // "reflect"
  4. "testing"
  5. "app.yhyue.com/moapp/jybase/mongodb"
  6. "app.yhyue.com/moapp/jybase/mysql"
  7. "app.yhyue.com/moapp/jybase/redis"
  8. "bp.jydev.jianyu360.cn/BaseService/entManageApplication/entity"
  9. "bp.jydev.jianyu360.cn/BaseService/entManageApplication/rpc/pb"
  10. "bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/usercenter"
  11. "github.com/zeromicro/go-zero/core/discov"
  12. "github.com/zeromicro/go-zero/zrpc"
  13. )
  14. func init() {
  15. entity.JyMysql = &mysql.Mysql{
  16. Address: "192.168.3.11:3366",
  17. UserName: "root",
  18. PassWord: "Topnet123",
  19. DBName: "jianyu",
  20. MaxOpenConns: 5,
  21. MaxIdleConns: 5,
  22. }
  23. entity.JyMysql.Init()
  24. entity.Mgo = mongodb.NewMgo("192.168.3.206:27080", "qfw", 10)
  25. redis.InitRedisBySize("newother=192.168.3.206:1712", 100, 30, 300)
  26. //用户中台配置
  27. userClient := zrpc.MustNewClient(zrpc.RpcClientConf{
  28. Etcd: discov.EtcdConf{
  29. Hosts: []string{"192.168.3.149:2379"},
  30. Key: "usercenter.rpc",
  31. },
  32. })
  33. entity.UserCenterRpc = usercenter.NewUserCenter(userClient)
  34. }
  35. func TestAddUsePerson(t *testing.T) {
  36. tests := []struct {
  37. name string
  38. args *pb.AddUsePersonReq
  39. want string
  40. }{
  41. {
  42. name: "添加使用人员",
  43. args: &pb.AddUsePersonReq{
  44. EntId: 15051,
  45. EntUserId: "4623",
  46. WaitEmpowerId: 432,
  47. },
  48. want: "",
  49. },
  50. }
  51. for _, tt := range tests {
  52. t.Run(tt.name, func(t *testing.T) {
  53. AddUsePerson(tt.args)
  54. // if got := AddUsePerson(tt.args); !reflect.DeepEqual(got, tt.want) {
  55. // t.Errorf("AddUsePerson() = %v, want %v", got, tt.want)
  56. // }
  57. })
  58. }
  59. }
  60. func TestBuyProductList(t *testing.T) {
  61. tests := []struct {
  62. name string
  63. args *pb.BuyProductListReq
  64. want string
  65. }{
  66. {
  67. name: "已购产品列表",
  68. args: &pb.BuyProductListReq{
  69. EntId: 15023,
  70. },
  71. want: "",
  72. },
  73. }
  74. for _, tt := range tests {
  75. t.Run(tt.name, func(t *testing.T) {
  76. BuyProductList(tt.args)
  77. // if got := BuyProductList(tt.args); !reflect.DeepEqual(got, tt.want) {
  78. // t.Errorf("BuyProductList() = %v, want %v", got, tt.want)
  79. // }
  80. })
  81. }
  82. }
  83. func TestDelUsePerson(t *testing.T) {
  84. tests := []struct {
  85. name string
  86. args *pb.DelUsePersonReq
  87. want string
  88. }{
  89. {
  90. name: "删除使用人员",
  91. args: &pb.DelUsePersonReq{
  92. EntnichePowerId: 52,
  93. },
  94. want: "",
  95. },
  96. }
  97. for _, tt := range tests {
  98. t.Run(tt.name, func(t *testing.T) {
  99. DelUsePerson(tt.args)
  100. // if got := DelUsePerson(tt.args); !reflect.DeepEqual(got, tt.want) {
  101. // t.Errorf("DelUsePerson() = %v, want %v", got, tt.want)
  102. // }
  103. })
  104. }
  105. }
  106. func TestUsePersonList(t *testing.T) {
  107. tests := []struct {
  108. name string
  109. args *pb.UsePersonListReq
  110. want string
  111. }{
  112. {
  113. name: "使用人员列表",
  114. args: &pb.UsePersonListReq{
  115. EntId: 15023,
  116. WaitEmpowerId: 18,
  117. },
  118. want: "",
  119. },
  120. }
  121. for _, tt := range tests {
  122. t.Run(tt.name, func(t *testing.T) {
  123. UsePersonList(tt.args)
  124. // if got := UsePersonList(tt.args); !reflect.DeepEqual(got, tt.want) {
  125. // t.Errorf("UsePersonList() = %v, want %v", got, tt.want)
  126. // }
  127. })
  128. }
  129. }
  130. func TestEmpowerUserIds(t *testing.T) {
  131. t.Log(EmpowerUserIds([]int64{5388, 5391}).Ids)
  132. }