package service import ( quitl "app.yhyue.com/moapp/jybase/common" "app.yhyue.com/moapp/jybase/mysql" "bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity" "bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/rpc/medical/medical" "fmt" "math/rand" "reflect" "testing" ) func init() { entity.BaseMysql = &mysql.Mysql{ Address: "192.168.3.217:4000", UserName: "root", PassWord: "=PDT49#80Z!RVv52_z", DBName: "base_service", MaxOpenConns: 5, MaxIdleConns: 5, } entity.BaseMysql.Init() } func TestAuthService_UserAuthInfo(t *testing.T) { type args struct { in *medical.CommonReq } tests := []struct { name string args args want *map[string]interface{} }{ // TODO: Add test cases. { name: "用户认证信息-认证", args: args{ &medical.CommonReq{ UserId: "123", Appid: "10000", }, }, }, { name: "用户认证信息-未认证", args: args{ &medical.CommonReq{ UserId: quitl.InterfaceToStr(rand.Int63n(100000000000)), }, }, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { b := AuthService{} if got := b.UserAuthInfo(tt.args.in); !reflect.DeepEqual(got, tt.want) { t.Errorf("UserAuthInfo() = %v, want %v", got, tt.want) } }) } } func TestAuthService_UserAuthInfoSave(t *testing.T) { type args struct { in *medical.UserInfo } tests := []struct { name string args args want bool want1 string }{ // TODO: Add test cases. { name: "用户认证信息保存", args: args{ &medical.UserInfo{ UserId: quitl.InterfaceToStr(rand.Int63n(100000000000)), Mail: "qqq.com", Phone: "13111111111", Name: fmt.Sprintf("用户%d", rand.Int63n(1000)), Position: "经理", Department: "公关", EntCode: "11111", EntName: "测试企业", OperationType: "add", Appid: "10000", }, }}, { name: "用户认证信息保存-用户已认证", args: args{ &medical.UserInfo{ UserId: "36685456029", Mail: "qqq.com", Phone: "13111111111", Name: fmt.Sprintf("用户%d", rand.Int63n(1000)), Position: "经理", Department: "公关", EntCode: "11111", EntName: "测试企业", OperationType: "add", Appid: "10000", }, }}, { name: "用户认证信息修改", args: args{ &medical.UserInfo{ UserId: "36685456029", Mail: "qqq.com", Phone: "13111111111", Name: fmt.Sprintf("用户%d", rand.Int63n(1000)), Position: "经理", Department: "公关", EntCode: "11111", EntName: "测试企业", OperationType: "update", Appid: "10000", }, }, }, { name: "用户认证信息修改-未认证", args: args{ &medical.UserInfo{ UserId: "11111", Mail: "qqq.com", Phone: "13111111111", Name: fmt.Sprintf("用户%d", rand.Int63n(1000)), Position: "经理", Department: "公关", EntCode: "11111", EntName: "测试企业", OperationType: "update", Appid: "10000", }, }, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { b := AuthService{} got, got1 := b.UserAuthInfoSave(tt.args.in) if got != tt.want { t.Errorf("UserAuthInfoSave() got = %v, want %v", got, tt.want) } if got1 != tt.want1 { t.Errorf("UserAuthInfoSave() got1 = %v, want %v", got1, tt.want1) } }) } }