forked from cherryservers/cherrygo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
users_test.go
47 lines (41 loc) · 1.04 KB
/
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 cherrygo
import (
"fmt"
"net/http"
"reflect"
"testing"
)
func TestUser_Current(t *testing.T) {
setup()
defer teardown()
expected := User{
ID: 123,
FirstName: "Ei",
LastName: "Jei",
Email: "[email protected]",
EmailVerified: true,
Phone: "37060000000",
SecurityPhone: "37060000000",
SecurityPhoneVerified: false,
}
mux.HandleFunc("/v1/user", func(writer http.ResponseWriter, request *http.Request) {
testMethod(t, request, http.MethodGet)
fmt.Fprint(writer, `{
"id":123,
"first_name": "Ei",
"last_name": "Jei",
"email": "[email protected]",
"email_verified": true,
"phone": "37060000000",
"security_phone": "37060000000",
"security_phone_verified": false
}`)
})
user, _, err := client.Users.CurrentUser(nil)
if err != nil {
t.Errorf("Users.CurrentUser returned %+v", err)
}
if !reflect.DeepEqual(user, expected) {
t.Errorf("Users.CurrentUser returned %+v, expected %+v", user, expected)
}
}