-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathpublic_test.go
95 lines (72 loc) · 2.25 KB
/
public_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 wex
import (
. "github.com/smartystreets/goconvey/convey"
"testing"
)
var api = PublicAPI{}
func TestTicker(t *testing.T) {
Convey("Ticker data for BTC-USD", t, func() {
tickers, err := api.Ticker([]string{"btc_usd"})
Convey("No error should occur", func() {
So(err, ShouldBeNil)
})
Convey("One ticker information should be returned", func() {
So(tickers, ShouldHaveSameTypeAs, Ticker{})
So(tickers, ShouldContainKey, "btc_usd")
So(tickers["btc_usd"], ShouldHaveSameTypeAs, TickerPair{})
})
})
Convey("Ticker data for BTC-USD and BTC-BTC", t, func() {
_, err := api.Ticker([]string{"btc_usd", "btc_btc"})
Convey("Error should occur", func() {
So(err, ShouldNotBeNil)
})
})
Convey("Ticker data for BTC-USD and BTC-BTC with the ignore invalid flag", t, func() {
tickers, err := api.Ticker([]string{"btc_usd", "btc_btc"}, true)
Convey("No error should occur", func() {
So(err, ShouldBeNil)
})
Convey("One ticker information should be returned", func() {
So(tickers, ShouldHaveSameTypeAs, Ticker{})
So(tickers, ShouldContainKey, "btc_usd")
So(tickers["btc_usd"], ShouldHaveSameTypeAs, TickerPair{})
})
})
}
func TestInfo(t *testing.T) {
Convey("Information data", t, func() {
information, err := api.Info()
Convey("No error should occur", func() {
So(err, ShouldBeNil)
})
Convey("Information data for 'btc_usd' should be returned", func() {
So(information, ShouldHaveSameTypeAs, Info{})
So(information.Pairs["btc_usd"], ShouldHaveSameTypeAs, InfoPair{})
})
})
}
func TestDepth(t *testing.T) {
Convey("Depth data", t, func() {
depth, err := api.Depth([]string{"btc_usd"}, 1)
Convey("No error should occur", func() {
So(err, ShouldBeNil)
})
Convey("Depth data for 'btc_usd' should be returned", func() {
So(depth, ShouldHaveSameTypeAs, Depth{})
So(depth["btc_usd"], ShouldHaveSameTypeAs, DepthPair{})
})
})
}
func TestTrade(t *testing.T) {
Convey("Trade data", t, func() {
trade, err := api.Trades([]string{"btc_usd"}, 1)
Convey("No error should occur", func() {
So(err, ShouldBeNil)
})
Convey("Trade data for 'btc_usd' should be returned", func() {
So(trade, ShouldHaveSameTypeAs, Trades{})
So(len(trade["btc_usd"]), ShouldBeGreaterThanOrEqualTo, 0)
})
})
}