-
Notifications
You must be signed in to change notification settings - Fork 145
/
profile_test.go
76 lines (64 loc) · 1.29 KB
/
profile_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
package coinbasepro
import (
"errors"
"fmt"
"testing"
)
func TestGetProfiles(t *testing.T) {
client := NewTestClient()
profiles, err := client.GetProfiles()
if err != nil {
t.Error(err)
}
for _, p := range profiles {
if p.ID == "" {
t.Error(errors.New("profile id missing"))
}
}
}
func TestGetProfile(t *testing.T) {
client := NewTestClient()
profiles, err := client.GetProfiles()
if err != nil {
t.Error(err)
}
profile, err := client.GetProfile(profiles[0].ID)
if err != nil {
t.Error(err)
}
if profile.ID == "" {
t.Error(errors.New("profile id missing"))
}
}
func TestCreateProfileTransfer(t *testing.T) {
client := NewTestClient()
profiles, err := client.GetProfiles()
if err != nil {
t.Error(err)
}
var fromProfile, toProfile Profile
for _, profile := range profiles {
if profile.IsDefault {
fromProfile = profile
continue
}
if profile.Active {
toProfile = profile
break
}
}
if toProfile.ID == "" {
t.Skip(fmt.Sprintf("needed at least two active profiles for this test"))
}
// Send from first profile to second profile
newTransfer := ProfileTransfer{
From: fromProfile.ID,
To: toProfile.ID,
Currency: "USD",
Amount: "9.99",
}
err = client.CreateProfileTransfer(&newTransfer)
if err != nil {
t.Error(err)
}
}