This repository has been archived by the owner on Sep 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
exchange_test.go
executable file
·70 lines (63 loc) · 1.61 KB
/
exchange_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
// NOTE: before testing, apply your CMC API key to init() of `coinmarketcap_test.go`
package coinmarketcap
import (
"testing"
"github.com/hexoul/go-coinmarketcap/types"
)
func TestExchangeInfo(t *testing.T) {
if info, err := GetInstance().ExchangeInfo(&types.Options{
Slug: "binance",
}); err != nil {
t.Fatal(err)
} else if info.ExchangeInfo["binance"].Name != "Binance" {
t.FailNow()
}
}
func TestExchangeMap(t *testing.T) {
if info, err := GetInstance().ExchangeMap(&types.Options{
Slug: "binance",
}); err != nil {
t.Fatal(err)
} else if len(info.ExchangeMap) == 0 {
t.FailNow()
} else if info.ExchangeMap[0].Name != "Binance" {
t.FailNow()
}
}
func TestExchangeListingsLatest(t *testing.T) {
if info, err := GetInstance().ExchangeListingsLatest(&types.Options{
Limit: 2,
}); err != nil {
t.Fatal(err)
} else if len(info.MarketQuote) < 2 {
t.FailNow()
} else if info.MarketQuote[0].Name == "" {
t.FailNow()
}
}
func TestExchangeMarketPairsLatest(t *testing.T) {
if info, err := GetInstance().ExchangeMarketPairsLatest(&types.Options{
Slug: "binance",
Limit: 200,
Convert: "USD",
}); err != nil {
t.Fatal(err)
} else if info.Name != "Binance" {
t.FailNow()
} else {
for _, pair := range info.MarketPair {
t.Log(pair.MarketPair, pair.Quote["USD"].Price)
}
}
}
func TestExchangeMarketQuotesLatest(t *testing.T) {
if info, err := GetInstance().ExchangeMarketQuotesLatest(&types.Options{
Slug: "binance",
}); err != nil {
t.Fatal(err)
} else if len(info.MarketQuote) == 0 {
t.FailNow()
} else if info.MarketQuote["binance"].Name != "Binance" {
t.FailNow()
}
}