package wechat import ( "github.com/fonchain_enterprise/micro-account/pkg/cache" "reflect" "testing" ) func TestGetOpenID(t *testing.T) { redisConfig := cache.RedisConfig{ RedisDB: "2", RedisAddr: "127.0.0.1:6379", RedisPw: "", RedisDbName: "2", } cache.LoadRedis(redisConfig) type args struct { appID string appSecret string code string } tests := []struct { name string args args wantOpenInfo *OpenIDInfo wantErr bool }{ {name: "", args: args{appID: "wx2ab0adfa3346d44f", appSecret: "d85d38e7a055432254a09f00899971c8", code: "xxx"}, wantOpenInfo: &OpenIDInfo{}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { gotOpenInfo, err := GetBoxOpenID(tt.args.appID, tt.args.appSecret, tt.args.code) if (err != nil) != tt.wantErr { t.Errorf("GetOpenID() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(gotOpenInfo, tt.wantOpenInfo) { t.Errorf("GetOpenID() gotOpenInfo = %v, want %v", gotOpenInfo, tt.wantOpenInfo) } }) } } func TestGetBoxPhone(t *testing.T) { redisConfig := cache.RedisConfig{ RedisDB: "2", RedisAddr: "127.0.0.1:6379", RedisPw: "", RedisDbName: "2", } cache.LoadRedis(redisConfig) type args struct { appID string appSecret string code string } tests := []struct { name string args args want string wantErr bool }{ {name: "", args: args{appID: "wx2ab0adfa3346d44f", appSecret: "d85d38e7a055432254a09f00899971c8", code: "xxx"}}, // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { got, err := GetBoxPhone(tt.args.appID, tt.args.appSecret, tt.args.code) if (err != nil) != tt.wantErr { t.Errorf("GetBoxPhone() error = %v, wantErr %v", err, tt.wantErr) return } if got != tt.want { t.Errorf("GetBoxPhone() got = %v, want %v", got, tt.want) } }) } }