123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- 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)
- }
- })
- }
- }
|