-
Notifications
You must be signed in to change notification settings - Fork 4
/
user_test.go
56 lines (46 loc) · 1.39 KB
/
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
package mite_test
import (
"os"
"testing"
"github.com/gosticks/go-mite"
)
func TestGetUsers(t *testing.T) {
username, okUser := os.LookupEnv("MITE_USER")
team, okAddr := os.LookupEnv("MITE_TEAM")
key, okKey := os.LookupEnv("MITE_APIKEY")
if !okAddr || !okUser || !okKey {
t.Errorf("username=%s, team=%s and key=%s are required", username, team, key)
t.FailNow()
}
mite := mite.NewMiteAPI(username, team, key, "test@go-mite")
_, errUser := mite.GetUsers(false)
if errUser != nil {
t.Error(username, team, key, errUser)
}
_, errArchivedUser := mite.GetUsers(true)
if errArchivedUser != nil {
t.Error(username, team, key, errUser)
}
}
func TestGetUser(t *testing.T) {
username, okUser := os.LookupEnv("MITE_USER")
team, okAddr := os.LookupEnv("MITE_TEAM")
key, okKey := os.LookupEnv("MITE_APIKEY")
if !okAddr || !okUser || !okKey {
t.Errorf("username=%s, team=%s and key=%s are required", username, team, key)
t.FailNow()
}
mite := mite.NewMiteAPI(username, team, key, "test@go-mite")
users, errUser := mite.GetUsers(false)
if errUser != nil {
t.Error(username, team, key, errUser)
}
for _, user := range users {
_, errUser := mite.GetUser(user.ID)
if errUser != nil {
t.Errorf("Failed to get the user available in the user map username=%s id=%d", user.Name, user.ID)
t.FailNow()
}
}
t.Logf("Got all users available for account by id (total %d)", len(users))
}