forked from Kucoin/kucoin-go-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcurrency_test.go
94 lines (89 loc) · 1.93 KB
/
currency_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
package kucoin
import (
"testing"
)
func TestApiService_Currencies(t *testing.T) {
s := NewApiServiceFromEnv()
rsp, err := s.Currencies()
if err != nil {
t.Fatal(err)
}
cl := CurrenciesModel{}
if err := rsp.ReadData(&cl); err != nil {
t.Fatal(err)
}
for _, c := range cl {
t.Log(ToJsonString(c))
switch {
case c.Name == "":
t.Error("Empty key 'name'")
case c.Currency == "":
t.Error("Empty key 'currency'")
case c.FullName == "":
t.Error("Empty key 'fullName'")
case c.WithdrawalMinSize == "":
t.Error("Empty key 'withdrawalMinSize'")
case c.WithdrawalMinFee == "":
t.Error("Empty key 'withdrawalMinFee'")
}
}
}
func TestApiService_Currency(t *testing.T) {
s := NewApiServiceFromEnv()
rsp, err := s.Currency("BTC", "")
if err != nil {
t.Fatal(err)
}
c := &CurrencyModel{}
if err := rsp.ReadData(c); err != nil {
t.Fatal(err)
}
t.Log(ToJsonString(c))
switch {
case c.Name == "":
t.Error("Empty key 'name'")
case c.Currency == "":
t.Error("Empty key 'currency'")
case c.FullName == "":
t.Error("Empty key 'fullName'")
case c.WithdrawalMinSize == "":
t.Error("Empty key 'withdrawalMinSize'")
case c.WithdrawalMinFee == "":
t.Error("Empty key 'withdrawalMinFee'")
}
}
func TestApiService_Currency_V2(t *testing.T) {
s := NewApiServiceFromEnv()
rsp, err := s.CurrencyV2("BTC", "")
if err != nil {
t.Fatal(err)
}
c := &CurrencyV2Model{}
if err := rsp.ReadData(c); err != nil {
t.Fatal(err)
}
t.Log(ToJsonString(c))
switch {
case c.Name == "":
t.Error("Empty key 'name'")
case c.Currency == "":
t.Error("Empty key 'currency'")
case c.FullName == "":
t.Error("Empty key 'fullName'")
}
}
func TestApiService_Prices(t *testing.T) {
s := NewApiServiceFromEnv()
rsp, err := s.Prices("USD", "BTC,KCS")
if err != nil {
t.Fatal(err)
}
p := PricesModel{}
if err := rsp.ReadData(&p); err != nil {
t.Fatal(err)
}
if len(p) == 0 {
t.Error("Empty prices")
}
t.Log(ToJsonString(p))
}