getsublistlogic_test.go 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. "context"
  8. "github.com/zeromicro/go-zero/core/logx"
  9. "jyBXSubscribe/entity"
  10. IC "jyBXSubscribe/rpc/init"
  11. "jyBXSubscribe/rpc/internal/config"
  12. "jyBXSubscribe/rpc/internal/svc"
  13. "jyBXSubscribe/rpc/type/bxsubscribe"
  14. "log"
  15. "reflect"
  16. "strings"
  17. "testing"
  18. )
  19. func init() {
  20. logx.Info("--初始化 mongodb--")
  21. IC.Mgo = mongodb.MongodbSim{
  22. MongodbAddr: "192.168.3.206:27080",
  23. Size: 5,
  24. DbName: "qfw",
  25. }
  26. IC.Mgo.InitPool()
  27. IC.DB = config.Db{Mongo: entity.Mongo{
  28. Bidding: &entity.MongoStruct{
  29. Collection: "bidding",
  30. CollectionBack: "bidding_back",
  31. },
  32. }}
  33. IC.DB.Mongo.Bidding.Collection = "bidding_back"
  34. //
  35. logx.Info("--初始化 mongodb bidding--")
  36. IC.MgoBidding = mongodb.MongodbSim{
  37. MongodbAddr: "192.168.3.206:27001",
  38. Size: 5,
  39. DbName: "qfw_data",
  40. UserName: "jyDevGroup",
  41. Password: "jy@DevGroup",
  42. }
  43. IC.MgoBidding.InitPool()
  44. logx.Info("--初始化 mysql--")
  45. IC.MainMysql = &mysql.Mysql{
  46. Address: "192.168.3.11:3366",
  47. UserName: "root",
  48. PassWord: "Topnet123",
  49. DBName: "jianyu",
  50. MaxOpenConns: 5,
  51. MaxIdleConns: 5,
  52. }
  53. IC.MainMysql.Init()
  54. //初始化 mysql-EntnichePush
  55. logx.Info("--初始化 商机管理推送 mysql--")
  56. IC.BaseServiceMysql = &mysql.Mysql{
  57. Address: "192.168.3.217:4000",
  58. UserName: "root",
  59. PassWord: "=PDT49#80Z!RVv52_z",
  60. DBName: "base_service",
  61. MaxOpenConns: 5,
  62. MaxIdleConns: 5,
  63. }
  64. IC.BaseServiceMysql.Init()
  65. //初始化 mysql-GlobalCommonData
  66. logx.Info("--初始化 推送 mysql--")
  67. IC.GlobalCommonData = &mysql.Mysql{
  68. Address: "192.168.3.217:4000",
  69. UserName: "root",
  70. PassWord: "=PDT49#80Z!RVv52_z",
  71. DBName: "global_common_data",
  72. MaxOpenConns: 5,
  73. MaxIdleConns: 5,
  74. }
  75. IC.GlobalCommonData.Init()
  76. logx.Info("--初始化 redis--")
  77. 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)
  78. //初始化 elasticsearch
  79. logx.Info("--初始化 elasticsearch--")
  80. elastic.InitElasticSize("http://192.168.3.206:9800", 5)
  81. //IC.PushMapping.Init(IC.GlobalCommonData)
  82. }
  83. func TestGetSubListLogic_GetSubList(t *testing.T) {
  84. type fields struct {
  85. ctx context.Context
  86. svcCtx *svc.ServiceContext
  87. Logger logx.Logger
  88. }
  89. type args struct {
  90. in *bxsubscribe.SubscribeInfosReq
  91. }
  92. tests := []struct {
  93. name string
  94. fields fields
  95. args args
  96. want *bxsubscribe.SubscribeInfosResp
  97. wantErr bool
  98. }{
  99. // TODO: Add test cases.
  100. {
  101. name: "推送记录查看",
  102. fields: fields{},
  103. args: args{
  104. in: &bxsubscribe.SubscribeInfosReq{
  105. PageNum: 1,
  106. PageSize: 20,
  107. SelectTime: "",
  108. Area: "",
  109. City: "",
  110. BuyerClass: "人大,政协,党委办,组织,宣传,统战,纪委,政府办,发改委,财政,教育,科技,工信,民政,民宗,人社,公安,检察院,法院,司法,应急管理,军队,自然资源,生态环境,住建,市政,城管,交通,水利,农业,气象,文旅,卫健委,医疗,学校,档案,体育,政务中心,机关事务,国资委,海关,税务,市场监管,商务,人行,银保监,证监,审计,出版广电,统计,公共资源交易,社会团体",
  111. Subtype: "",
  112. KeyWords: "",
  113. Industry: "",
  114. UserType: "mType",
  115. UserId: "5e8eb60ae138234b4f91aacf",
  116. EntId: "1111",
  117. AppId: "10000",
  118. Price: "",
  119. FileExists: "",
  120. EntUserId: "",
  121. DeptId: "1111",
  122. NewUserId: 72668,
  123. },
  124. },
  125. want: nil,
  126. wantErr: true,
  127. },
  128. }
  129. for _, tt := range tests {
  130. t.Run(tt.name, func(t *testing.T) {
  131. l := &GetSubListLogic{
  132. ctx: tt.fields.ctx,
  133. svcCtx: tt.fields.svcCtx,
  134. Logger: tt.fields.Logger,
  135. }
  136. got, err := l.GetSubList(tt.args.in)
  137. log.Println(got)
  138. if (err != nil) != tt.wantErr {
  139. t.Errorf("GetSubList() error = %v, wantErr %v", err, tt.wantErr)
  140. return
  141. }
  142. if !reflect.DeepEqual(got, tt.want) {
  143. t.Errorf("GetSubList() got = %v, want %v", got, tt.want)
  144. }
  145. })
  146. }
  147. }