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("newother=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, } //(userid string, baseUserId, accountId, entId, positionType, positionId int64) if got := this.Power("63e346b5d093bbbf6d1f7019", 425409, 60229, 15456, 1, 60170); !reflect.DeepEqual(got, tt.want) { log.Println(got.Vip) log.Println(got.Member) log.Println(got.Ent) log.Println(got.Entniche) log.Println(got.Free) t.Errorf("Power() = %v, want %v", got, tt.want) } }) } }