forked from preichenberger/go-coinbasepro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproduct_test.go
95 lines (82 loc) · 1.67 KB
/
product_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 coinbase
import (
"errors"
"testing"
"time"
)
func TestGetProducts(t *testing.T) {
client := NewTestClient()
products, err := client.GetProducts()
if err != nil {
t.Error(err)
}
for _, p := range products {
if StructHasZeroValues(p) {
t.Error(errors.New("Zero value"))
}
}
}
func TestGetBook(t *testing.T) {
client := NewTestClient()
_, err := client.GetBook("BTC-USD", 1)
if err != nil {
t.Error(err)
}
_, err = client.GetBook("BTC-USD", 2)
if err != nil {
t.Error(err)
}
_, err = client.GetBook("BTC-USD", 3)
if err != nil {
t.Error(err)
}
}
func TestGetTicker(t *testing.T) {
client := NewTestClient()
ticker, err := client.GetTicker("BTC-USD")
if err != nil {
t.Error(err)
}
if StructHasZeroValues(ticker) {
t.Error(errors.New("Zero value"))
}
}
func TestListTrades(t *testing.T) {
var trades []Trade
client := NewTestClient()
cursor := client.ListTrades("BTC-USD")
for cursor.HasMore {
if err := cursor.NextPage(&trades); err != nil {
t.Error(err)
}
for _, a := range trades {
if StructHasZeroValues(a) {
t.Error(errors.New("Zero value"))
}
}
}
}
func TestGetHistoricRates(t *testing.T) {
client := NewTestClient()
params := GetHistoricRatesParams{
Start: time.Now().Add(-24 * 4 * time.Hour),
End: time.Now().Add(-24 * 2 * time.Hour),
Granularity: 1000,
}
_, err := client.GetHistoricRates("BTC-USD", params)
if err != nil {
t.Error(err)
}
}
func TestGetStats(t *testing.T) {
// Test server is busted
return
client := NewTestClient()
stats, err := client.GetStats("BTC-USD")
if err != nil {
t.Error(err)
}
if StructHasZeroValues(stats) {
t.Error(errors.New("Zero value"))
}
}