forked from equinixmetal-archive/packngo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
user_test.go
95 lines (76 loc) · 1.74 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package packngo
import (
"testing"
)
func TestAccUserCurrent(t *testing.T) {
skipUnlessAcceptanceTestsAllowed(t)
c, stopRecord := setup(t)
defer stopRecord()
u, _, err := c.Users.Current()
if err != nil {
t.Fatal(err)
}
if u.DefaultOrganizationID == "" {
t.Fatal("Expected DefaultOrganizationID should not be empty")
}
}
func TestAccUsersList(t *testing.T) {
skipUnlessAcceptanceTestsAllowed(t)
c, stopRecord := setup(t)
defer stopRecord()
us, _, err := c.Users.List(nil)
if err != nil {
t.Fatal(err)
}
if len(us) == 0 {
t.Fatal("At least the current user shall be listed")
}
u, _, err := c.Users.Get(us[0].ID, &GetOptions{Includes: []string{"emails"}})
if err != nil {
t.Fatal(err)
}
if u.Emails[0].Address == "" {
t.Fatal("User email should have been included.")
}
}
/*
func strPtr(s string) *string {
return &s
}
func TestAccUserUpdate(t *testing.T) {
skipUnlessAcceptanceTestsAllowed(t)
c, stopRecord := setup(t)
defer stopRecord()
u, _, err := c.Users.Current()
if err != nil {
t.Fatal(err)
}
if u.DefaultOrganizationID == "" {
t.Fatal("Expected DefaultOrganizationID should not be empty")
}
testFirst := "test firstname"
testLast := "test lasstname"
uur := UserUpdateRequest{
FirstName: strPtr(testFirst),
LastName: strPtr(testLast),
}
uu, _, err := c.Users.Update(&uur)
if err != nil {
t.Fatal(err)
}
if uu.LastName != testLast {
t.Fatalf("Updated last name should be %s, was %s", testLast, uu.LastName)
}
if uu.FirstName != testFirst {
t.Fatalf("Updated first name should be %s, was %s", testFirst, uu.FirstName)
}
orig := UserUpdateRequest{
FirstName: strPtr(u.FirstName),
LastName: strPtr(u.LastName),
}
_, _, err = c.Users.Update(&orig)
if err != nil {
t.Fatal(err)
}
}
*/