getsublistlogic_test.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. logx.Info("--初始化 redis--")
  66. 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)
  67. //初始化 elasticsearch
  68. logx.Info("--初始化 elasticsearch--")
  69. elastic.InitElasticSize("http://192.168.3.206:9800", 5)
  70. }
  71. func TestGetSubListLogic_GetSubList(t *testing.T) {
  72. type fields struct {
  73. ctx context.Context
  74. svcCtx *svc.ServiceContext
  75. Logger logx.Logger
  76. }
  77. type args struct {
  78. in *bxsubscribe.SubscribeInfosReq
  79. }
  80. tests := []struct {
  81. name string
  82. fields fields
  83. args args
  84. want *bxsubscribe.SubscribeInfosResp
  85. wantErr bool
  86. }{
  87. // TODO: Add test cases.
  88. {
  89. name: "推送记录查看",
  90. fields: fields{},
  91. args: args{
  92. in: &bxsubscribe.SubscribeInfosReq{
  93. PageNum: 1,
  94. PageSize: 20,
  95. SelectTime: "",
  96. Area: "",
  97. City: "",
  98. Industry: "",
  99. BuyerClass: "",
  100. KeyWords: "",
  101. Subtype: "",
  102. UserType: "mType",
  103. UserId: "5e8eb60ae138234b4f91aacf",
  104. EntId: "1111",
  105. AppId: "10000",
  106. Price: "",
  107. FileExists: "",
  108. EntUserId: "",
  109. DeptId: "1111",
  110. NewUserId: 11111,
  111. },
  112. },
  113. want: nil,
  114. wantErr: true,
  115. },
  116. }
  117. for _, tt := range tests {
  118. t.Run(tt.name, func(t *testing.T) {
  119. l := &GetSubListLogic{
  120. ctx: tt.fields.ctx,
  121. svcCtx: tt.fields.svcCtx,
  122. Logger: tt.fields.Logger,
  123. }
  124. got, err := l.GetSubList(tt.args.in)
  125. log.Println(got)
  126. if (err != nil) != tt.wantErr {
  127. t.Errorf("GetSubList() error = %v, wantErr %v", err, tt.wantErr)
  128. return
  129. }
  130. if !reflect.DeepEqual(got, tt.want) {
  131. t.Errorf("GetSubList() got = %v, want %v", got, tt.want)
  132. }
  133. })
  134. }
  135. }