-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbinance_test.go
65 lines (62 loc) · 1.23 KB
/
binance_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
package marketdata
import (
"reflect"
"testing"
"time"
)
func Test_binanceDOMResponse_toEntity(t *testing.T) {
tests := []struct {
name string
response binanceDOMResponse
market string
want DOM
}{
{
name: "success",
response: binanceDOMResponse{
Bids: [][]string{
{"93.18000000", "570.00000000"},
{"93.16000000", "56223.00000000"},
},
Asks: [][]string{
{"93.19000000", "971.00000000"},
{"93.20000000", "3975.00000000"},
},
},
market: "USDTRUB",
want: DOM{
Date: time.Now().UTC().Round(1 * time.Second),
Bids: []DOMPosition{
{
Price: "93.18000000",
Amount: "570.00000000",
},
{
Price: "93.16000000",
Amount: "56223.00000000",
},
},
Asks: []DOMPosition{
{
Price: "93.19000000",
Amount: "971.00000000",
},
{
Price: "93.20000000",
Amount: "3975.00000000",
},
},
},
},
//TODO
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := tt.response.toEntity(tt.market)
got.Date = got.Date.Round(1 * time.Second)
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("binanceDOMResponse.toEntity() = %v, want %v", got, tt.want)
}
})
}
}