-
Notifications
You must be signed in to change notification settings - Fork 77
/
currency_test.go
121 lines (114 loc) · 2.58 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package kucoin
import (
"context"
"testing"
)
func TestApiService_Currencies(t *testing.T) {
s := NewApiServiceFromEnv()
rsp, err := s.Currencies(context.Background())
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(context.Background(), "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(context.Background(), "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(context.Background(), "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))
}
func TestApiServiceCurrenciesV3(t *testing.T) {
s := NewApiServiceFromEnv()
rsp, err := s.CurrenciesV3(context.Background())
if err != nil {
t.Fatal(err)
}
p := CurrenciesV3Model{}
if err := rsp.ReadData(&p); err != nil {
t.Fatal(err)
}
t.Log(ToJsonString(p))
}
func TestApiService_CurrencyInfoV3(t *testing.T) {
s := NewApiServiceFromEnv()
rsp, err := s.CurrencyInfoV3(context.Background(), "BTC")
if err != nil {
t.Fatal(err)
}
p := CurrencyV3Model{}
if err := rsp.ReadData(&p); err != nil {
t.Fatal(err)
}
t.Log(ToJsonString(p))
}