-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusers_test.go
47 lines (42 loc) · 967 Bytes
/
users_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package jike_sdk_go
import (
"context"
"fmt"
"log"
"os"
"testing"
"time"
)
var (
client *Client
ctx = context.Background()
)
func TestMain(t *testing.M) {
client = NewClient(WithDebug(true))
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
loginReq := &LoginWithPhoneAndPasswordReq{
AreaCode: "+86",
MobilePhoneNumber: phoneNumber,
Password: password,
}
_, err := client.LoginWithPhoneAndPassword(ctx, loginReq)
if err != nil {
log.Fatalln(err)
}
os.Exit(t.Run())
}
func TestClient_LoginWithPhoneAndPassword(t *testing.T) {
req := &LoginWithPhoneAndPasswordReq{
AreaCode: "+86",
MobilePhoneNumber: phoneNumber,
Password: password,
}
rsp, err := client.LoginWithPhoneAndPassword(ctx, req)
if err != nil {
t.Fatalf("%s\n", err)
}
fmt.Printf("%+v\n", rsp)
fmt.Printf("at: %s\n", client.xAccessToken)
fmt.Printf("rt: %s\n", client.xRefreshToken)
}