-
Notifications
You must be signed in to change notification settings - Fork 156
/
users_test.go
69 lines (57 loc) · 1.81 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package datadog
import (
"io/ioutil"
"net/http"
"net/http/httptest"
"testing"
)
func TestGetUser(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
response, err := ioutil.ReadFile("./tests/fixtures/users_response.json")
if err != nil {
t.Fatal(err)
}
w.Write(response)
}))
defer ts.Close()
datadogClient := Client{
baseUrl: ts.URL,
HttpClient: http.DefaultClient,
}
user, err := datadogClient.GetUser("[email protected]")
if err != nil {
t.Fatal(err)
}
expectedHandle := "[email protected]"
if handle := user.GetHandle(); handle != expectedHandle {
t.Fatalf("expect handle %s. Got %s", expectedHandle, handle)
}
expectedName := "test user"
if name := user.GetName(); name != expectedName {
t.Fatalf("expect name %s. Got %s", expectedName, name)
}
expectedEmail := "[email protected]"
if email := user.GetEmail(); email != expectedEmail {
t.Fatalf("expect email %s. Got %s", expectedEmail, email)
}
expectedAccessRole := "st"
if accessRole := user.GetAccessRole(); accessRole != expectedAccessRole {
t.Fatalf("expect access role %s. Got %s", expectedAccessRole, accessRole)
}
expectedIsAdmin := false
if isAdmin := user.GetIsAdmin(); isAdmin != expectedIsAdmin {
t.Fatalf("expect is_admin %t. Got %v", expectedIsAdmin, isAdmin)
}
expectedIsVerified := true
if isVerified := user.GetVerified(); isVerified != expectedIsVerified {
t.Fatalf("expect is_verified %t. Got %v", expectedIsVerified, isVerified)
}
expectedIsDisabled := false
if isVerified := user.GetDisabled(); isVerified != expectedIsDisabled {
t.Fatalf("expect is_disabled %t. Got %v", expectedIsDisabled, isVerified)
}
expectedRole := ""
if role := user.GetRole(); role != expectedRole {
t.Fatalf("expect role %s. Got %s", expectedRole, role)
}
}