-
Notifications
You must be signed in to change notification settings - Fork 3
/
bitmex_suite_test.go
65 lines (57 loc) · 1.49 KB
/
bitmex_suite_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 bitmex_test
import (
"encoding/json"
"io/ioutil"
"testing"
"time"
"github.com/adampointer/go-bitmex/types"
"github.com/go-openapi/strfmt"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/sirupsen/logrus"
"github.com/wacul/ptr"
)
func TestBitmex(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Bitmex Suite")
}
var _ = BeforeSuite(func() {
logrus.SetOutput(ioutil.Discard)
logrus.SetLevel(logrus.DebugLevel)
})
func fakeSubscriptionResponse(t GinkgoTInterface, table string, data interface{}) *types.CompositeResponse {
d := []interface{}{data}
j, err := json.Marshal(d)
if err != nil {
t.Fatal(err)
}
return &types.CompositeResponse{
SubscriptionResponse: types.SubscriptionResponse{
Table: table,
Action: "update",
Data: j,
},
Request: &types.Command{Op: types.CommandOpSubscribe, Args: types.CommandArgs{table}},
}
}
func fakeSuccessResponse(table string, success bool) *types.CompositeResponse {
return &types.CompositeResponse{
SuccessResponse: types.SuccessResponse{
Subscribe: table,
Success: ptr.Bool(success),
Request: &types.Command{Op: types.CommandOpSubscribe, Args: types.CommandArgs{table}},
},
Request: &types.Command{Op: types.CommandOpSubscribe, Args: types.CommandArgs{table}},
}
}
func last(_ interface{}) string {
return "0"
}
func DateTimePtr(timeString string) *strfmt.DateTime {
t, err := time.Parse(time.RFC822, timeString)
if err != nil {
panic(err)
}
d := strfmt.DateTime(t)
return &d
}