-
Notifications
You must be signed in to change notification settings - Fork 4
/
query_user_test.go
63 lines (56 loc) · 1.56 KB
/
query_user_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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package wrike_test
import (
"fmt"
"net/http"
"testing"
"gotest.tools/assert"
wrike "github.com/AkihikoITOH/wrike.go"
)
var userData = []byte(
`{
"kind": "users",
"data":
[
{
"id": "KUAAAAHP",
"firstName": "Test",
"lastName": "User",
"type": "Person",
"profiles":
[
{
"accountId": "IEAAAAG3",
"email": "[email protected]",
"role": "User",
"external": false,
"admin": false,
"owner": true
}
],
"avatarUrl": "https://dev.wrke.io/avatars//D7/A2/Box_ffffff00_84-84_v1.png",
"timezone": "Europe/Moscow",
"locale": "en",
"deleted": false,
"me": true
}
]
}`)
func Example_queryUser() {
conf := wrike.NewConfig("wrike-access-token", "")
api := wrike.NewAPI(conf)
api.QueryUser("KUAAAAHP")
}
func TestQueryUser(t *testing.T) {
client := NewMockClient(userData)
api := &wrike.API{Config: mockAPIConfig, HTTPClient: client}
user, err := api.QueryUser("KUAAAAHP")
if err != nil {
fmt.Println(err.Error())
}
// Check request object
assert.Equal(t, client.Request.Method, http.MethodGet)
assert.Equal(t, client.Request.URL.String(), "https://app-eu.wrike.com/api/v4/users/KUAAAAHP")
assert.Equal(t, client.Request.Body, nil)
SharedRequestTests(t, client.Request)
assert.Equal(t, string(user.Data[0].ID), "KUAAAAHP")
}