123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- package service
- import (
- "log"
- "reflect"
- "testing"
- "app.yhyue.com/moapp/jybase/mongodb"
- "app.yhyue.com/moapp/jybase/mysql"
- "app.yhyue.com/moapp/jybase/redis"
- "bp.jydev.jianyu360.cn/BaseService/powerCheckCenter/entity"
- )
- var MyConn *entity.Conn // 显式初始化数据库
- func init() {
- InitDb() // 显式初始化数据库
- }
- var NewPowerService PowerService
- func InitDb() *entity.Conn {
- //医疗机构配置
- MysqlConn := &mysql.Mysql{
- Address: "192.168.3.11:3366",
- UserName: "root",
- PassWord: "Topnet123",
- DBName: "jianyu",
- MaxOpenConns: 5,
- MaxIdleConns: 5,
- }
- MysqlConn.Init()
- //基本信息配置
- BaseMysqlConn := &mysql.Mysql{
- Address: "192.168.3.217:4000",
- UserName: "root",
- PassWord: "=PDT49#80Z!RVv52_z",
- DBName: "base_service",
- MaxOpenConns: 5,
- MaxIdleConns: 5,
- }
- BaseMysqlConn.Init()
- //mongo初始化
- MgoJy := &mongodb.MongodbSim{
- MongodbAddr: "192.168.3.206:27080",
- Size: 50,
- DbName: "qfw",
- }
- MgoJy.InitPool()
- MyConn := entity.Conn{
- Mysql: MysqlConn,
- BaseMysql: BaseMysqlConn,
- MgoJy: MgoJy,
- }
- redis.InitRedisBySize("other=192.168.3.206:1712", 100, 30, 300)
- log.Println("初始化成功。。")
- NewPowerService = *NewPower(&MyConn)
- return &MyConn
- }
- func TestNewPower(t *testing.T) {
- type args struct {
- conn *entity.Conn
- }
- tests := []struct {
- name string
- args args
- want *PowerService
- }{
- // TODO: Add test cases.
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- if got := NewPower(tt.args.conn); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("NewPower() = %v, want %v", got, tt.want)
- }
- })
- }
- }
- func TestPowerService_Power(t *testing.T) {
- type fields struct {
- Conn *entity.Conn
- }
- type args struct {
- userid string
- baseUserId int64
- accountId int64
- }
- tests := []struct {
- name string
- fields fields
- args args
- want *entity.Power
- }{
- // TODO: Add test cases.
- {
- args: args{},
- },
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- this := &PowerService{
- Conn: NewPowerService.Conn,
- }
- if got := this.Power("6103bb722abfa5f4d81bb1d1", 69871, 0, 15051); !reflect.DeepEqual(got, tt.want) {
- t.Errorf("Power() = %v, want %v", got, tt.want)
- }
- })
- }
- }
|