-
Notifications
You must be signed in to change notification settings - Fork 145
/
account_test.go
96 lines (84 loc) · 1.84 KB
/
account_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
96
package coinbasepro
import (
"errors"
"testing"
)
func TestGetAccounts(t *testing.T) {
client := NewTestClient()
accounts, err := client.GetAccounts()
if err != nil {
t.Error(err)
}
// Check for decoding issues
for _, a := range accounts {
if StructHasZeroValues(a) {
t.Error(errors.New("Zero value"))
}
}
}
func TestGetAccount(t *testing.T) {
client := NewTestClient()
accounts, err := client.GetAccounts()
if err != nil {
t.Error(err)
}
for _, a := range accounts {
account, err := client.GetAccount(a.ID)
if err != nil {
t.Error(err)
}
// Check for decoding issues
if StructHasZeroValues(account) {
t.Error(errors.New("Zero value"))
}
}
}
func TestListAccountLedger(t *testing.T) {
var ledgers []LedgerEntry
client := NewTestClient()
accounts, err := client.GetAccounts()
if err != nil {
t.Error(err)
}
for _, a := range accounts {
cursor := client.ListAccountLedger(a.ID)
for cursor.HasMore {
if err := cursor.NextPage(&ledgers); err != nil {
t.Error(err)
}
for _, ledger := range ledgers {
props := []string{"ID", "CreatedAt", "Amount", "Balance", "Type"}
if err := EnsureProperties(ledger, props); err != nil {
t.Error(err)
}
if ledger.Type == "match" || ledger.Type == "fee" {
if err := Ensure(ledger.Details); err != nil {
t.Error(errors.New("Details is missing"))
}
}
}
}
}
}
func TestListHolds(t *testing.T) {
var holds []Hold
client := NewTestClient()
accounts, err := client.GetAccounts()
if err != nil {
t.Error(err)
}
for _, a := range accounts {
cursor := client.ListHolds(a.ID)
for cursor.HasMore {
if err := cursor.NextPage(&holds); err != nil {
t.Error(err)
}
for _, h := range holds {
// Check for decoding issues
if StructHasZeroValues(h) {
t.Error(errors.New("Zero value"))
}
}
}
}
}