power_test.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. package service
  2. import (
  3. "log"
  4. "reflect"
  5. "testing"
  6. "app.yhyue.com/moapp/jybase/mongodb"
  7. "app.yhyue.com/moapp/jybase/mysql"
  8. "app.yhyue.com/moapp/jybase/redis"
  9. "bp.jydev.jianyu360.cn/BaseService/powerCheckCenter/entity"
  10. )
  11. var MyConn *entity.Conn // 显式初始化数据库
  12. func init() {
  13. InitDb() // 显式初始化数据库
  14. }
  15. var NewPowerService PowerService
  16. func InitDb() *entity.Conn {
  17. //医疗机构配置
  18. MysqlConn := &mysql.Mysql{
  19. Address: "192.168.3.11:3366",
  20. UserName: "root",
  21. PassWord: "Topnet123",
  22. DBName: "jianyu",
  23. MaxOpenConns: 5,
  24. MaxIdleConns: 5,
  25. }
  26. MysqlConn.Init()
  27. //基本信息配置
  28. BaseMysqlConn := &mysql.Mysql{
  29. Address: "192.168.3.217:4000",
  30. UserName: "root",
  31. PassWord: "=PDT49#80Z!RVv52_z",
  32. DBName: "base_service",
  33. MaxOpenConns: 5,
  34. MaxIdleConns: 5,
  35. }
  36. BaseMysqlConn.Init()
  37. //mongo初始化
  38. MgoJy := &mongodb.MongodbSim{
  39. MongodbAddr: "192.168.3.206:27080",
  40. Size: 50,
  41. DbName: "qfw",
  42. }
  43. MgoJy.InitPool()
  44. MyConn := entity.Conn{
  45. Mysql: MysqlConn,
  46. BaseMysql: BaseMysqlConn,
  47. MgoJy: MgoJy,
  48. }
  49. redis.InitRedisBySize("other=192.168.3.206:1712", 100, 30, 300)
  50. log.Println("初始化成功。。")
  51. NewPowerService = *NewPower(&MyConn)
  52. return &MyConn
  53. }
  54. func TestNewPower(t *testing.T) {
  55. type args struct {
  56. conn *entity.Conn
  57. }
  58. tests := []struct {
  59. name string
  60. args args
  61. want *PowerService
  62. }{
  63. // TODO: Add test cases.
  64. }
  65. for _, tt := range tests {
  66. t.Run(tt.name, func(t *testing.T) {
  67. if got := NewPower(tt.args.conn); !reflect.DeepEqual(got, tt.want) {
  68. t.Errorf("NewPower() = %v, want %v", got, tt.want)
  69. }
  70. })
  71. }
  72. }
  73. func TestPowerService_Power(t *testing.T) {
  74. type fields struct {
  75. Conn *entity.Conn
  76. }
  77. type args struct {
  78. userid string
  79. baseUserId int64
  80. accountId int64
  81. }
  82. tests := []struct {
  83. name string
  84. fields fields
  85. args args
  86. want *entity.Power
  87. }{
  88. // TODO: Add test cases.
  89. {
  90. args: args{},
  91. },
  92. }
  93. for _, tt := range tests {
  94. t.Run(tt.name, func(t *testing.T) {
  95. this := &PowerService{
  96. Conn: NewPowerService.Conn,
  97. }
  98. if got := this.Power("6103bb722abfa5f4d81bb1d1", 69871, 0, 15051); !reflect.DeepEqual(got, tt.want) {
  99. t.Errorf("Power() = %v, want %v", got, tt.want)
  100. }
  101. })
  102. }
  103. }