getsublistlogic_test.go 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. package logic
  2. import (
  3. elastic "app.yhyue.com/moapp/jybase/esv1"
  4. "app.yhyue.com/moapp/jybase/mongodb"
  5. "app.yhyue.com/moapp/jybase/mysql"
  6. "app.yhyue.com/moapp/jybase/redis"
  7. codePb "bp.jydev.jianyu360.cn/BaseService/jyCodeService/rpc/codeservice/codeservice"
  8. "context"
  9. "github.com/zeromicro/go-zero/core/discov"
  10. "github.com/zeromicro/go-zero/core/logx"
  11. "github.com/zeromicro/go-zero/zrpc"
  12. "jyBXSubscribe/entity"
  13. IC "jyBXSubscribe/rpc/init"
  14. "jyBXSubscribe/rpc/internal/config"
  15. "jyBXSubscribe/rpc/internal/svc"
  16. "jyBXSubscribe/rpc/type/bxsubscribe"
  17. "log"
  18. "reflect"
  19. "strings"
  20. "testing"
  21. )
  22. func init() {
  23. logx.Info("--初始化 mongodb--")
  24. IC.Mgo = mongodb.MongodbSim{
  25. MongodbAddr: "192.168.3.206:27080",
  26. Size: 5,
  27. DbName: "qfw",
  28. }
  29. IC.Mgo.InitPool()
  30. IC.DB = config.Db{Mongo: entity.Mongo{
  31. Bidding: &entity.MongoStruct{
  32. Collection: "bidding",
  33. CollectionBack: "bidding_back",
  34. },
  35. }}
  36. IC.DB.Mongo.Bidding.Collection = "bidding_back"
  37. //
  38. logx.Info("--初始化 mongodb bidding--")
  39. IC.MgoBidding = mongodb.MongodbSim{
  40. MongodbAddr: "192.168.3.206:27001",
  41. Size: 5,
  42. DbName: "qfw_data",
  43. UserName: "jyDevGroup",
  44. Password: "jy@DevGroup",
  45. }
  46. IC.MgoBidding.InitPool()
  47. logx.Info("--初始化 mysql--")
  48. IC.MainMysql = &mysql.Mysql{
  49. Address: "192.168.3.11:3366",
  50. UserName: "root",
  51. PassWord: "Topnet123",
  52. DBName: "jianyu",
  53. MaxOpenConns: 5,
  54. MaxIdleConns: 5,
  55. }
  56. IC.MainMysql.Init()
  57. //初始化 mysql-EntnichePush
  58. logx.Info("--初始化 商机管理推送 mysql--")
  59. IC.BaseServiceMysql = &mysql.Mysql{
  60. Address: "192.168.3.217:4000",
  61. UserName: "root",
  62. PassWord: "=PDT49#80Z!RVv52_z",
  63. DBName: "base_service",
  64. MaxOpenConns: 5,
  65. MaxIdleConns: 5,
  66. }
  67. IC.BaseServiceMysql.Init()
  68. //初始化 mysql-GlobalCommonData
  69. logx.Info("--初始化 推送 mysql--")
  70. IC.GlobalCommonData = &mysql.Mysql{
  71. Address: "192.168.3.217:4000",
  72. UserName: "root",
  73. PassWord: "=PDT49#80Z!RVv52_z",
  74. DBName: "global_common_data",
  75. MaxOpenConns: 5,
  76. MaxIdleConns: 5,
  77. }
  78. IC.GlobalCommonData.Init()
  79. logx.Info("--初始化 redis--")
  80. redis.InitRedisBySize(strings.Join([]string{"other=192.168.3.206:1712", "push=192.168.3.206:1712", "pushcache_1=192.168.3.206:5000", "pushcache_2_a=192.168.3.206:5001", "pushcache_2_b=192.168.3.206:5002"}, ","), 100, 30, 300)
  81. //初始化 elasticsearch
  82. logx.Info("--初始化 elasticsearch--")
  83. elastic.InitElasticSize("http://192.168.3.206:9800", 5)
  84. //代码表服务加载
  85. codeClient := zrpc.MustNewClient(zrpc.RpcClientConf{
  86. Etcd: discov.EtcdConf{
  87. Hosts: []string{"127.0.0.1:2379"},
  88. Key: "codeservice.rpc",
  89. },
  90. })
  91. logx.Info("CodeService初始化")
  92. IC.CodeLib = codePb.NewCodeService(codeClient)
  93. }
  94. func TestGetSubListLogic_GetSubList(t *testing.T) {
  95. type fields struct {
  96. ctx context.Context
  97. svcCtx *svc.ServiceContext
  98. Logger logx.Logger
  99. }
  100. type args struct {
  101. in *bxsubscribe.SubscribeInfosReq
  102. }
  103. tests := []struct {
  104. name string
  105. fields fields
  106. args args
  107. want *bxsubscribe.SubscribeInfosResp
  108. wantErr bool
  109. }{
  110. // TODO: Add test cases.
  111. {
  112. name: "推送记录查看",
  113. fields: fields{},
  114. args: args{
  115. in: &bxsubscribe.SubscribeInfosReq{
  116. PageNum: 1,
  117. PageSize: 50,
  118. SelectTime: "all",
  119. Area: "",
  120. City: "",
  121. BuyerClass: "",
  122. Subtype: "合同",
  123. KeyWords: "",
  124. Industry: "",
  125. UserType: "vType",
  126. UserId: "638af5cbb5b8a4e7edf5c8dc",
  127. EntId: "15186",
  128. AppId: "10000",
  129. Price: "",
  130. FileExists: "",
  131. EntUserId: "4852",
  132. DeptId: "",
  133. NewUserId: 335887,
  134. IsEnt: false,
  135. },
  136. },
  137. want: nil,
  138. wantErr: true,
  139. },
  140. }
  141. for _, tt := range tests {
  142. t.Run(tt.name, func(t *testing.T) {
  143. l := &GetSubListLogic{
  144. ctx: tt.fields.ctx,
  145. svcCtx: tt.fields.svcCtx,
  146. Logger: tt.fields.Logger,
  147. }
  148. got, err := l.GetSubList(tt.args.in)
  149. log.Println(got)
  150. if (err != nil) != tt.wantErr {
  151. t.Errorf("GetSubList() error = %v, wantErr %v", err, tt.wantErr)
  152. return
  153. }
  154. if !reflect.DeepEqual(got, tt.want) {
  155. t.Errorf("GetSubList() got = %v, want %v", got, tt.want)
  156. }
  157. })
  158. }
  159. }