-
Notifications
You must be signed in to change notification settings - Fork 69
/
user_stream_test.go
59 lines (46 loc) · 1.37 KB
/
user_stream_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
package binance_connector
import (
"testing"
"github.com/stretchr/testify/suite"
)
type userStreamTestSuite struct {
baseTestSuite
}
func TestUserStream(t *testing.T) {
suite.Run(t, new(userStreamTestSuite))
}
func (s *userStreamTestSuite) TestStartUserStream() {
data := []byte(`{
"listenKey": "pqia91ma19a5s61cv6a81va65sdf19v8a65a1a5s61cv6a81va65sdf19v8a65a1"
}`)
s.mockDo(data, nil)
defer s.assertDo()
s.assertReq(func(r *request) {
s.assertRequestEqual(newRequest(), r)
})
listenKey, err := s.client.NewCreateListenKeyService().Do(newContext())
s.r().NoError(err)
s.r().Equal("pqia91ma19a5s61cv6a81va65sdf19v8a65a1a5s61cv6a81va65sdf19v8a65a1", listenKey)
}
func (s *userStreamTestSuite) TestKeepaliveUserStream() {
data := []byte(`{}`)
s.mockDo(data, nil)
defer s.assertDo()
listenKey := "dummykey"
s.assertReq(func(r *request) {
s.assertRequestEqual(newRequest().setParam("listenKey", listenKey), r)
})
err := s.client.NewPingUserStream().ListenKey(listenKey).Do(newContext())
s.r().NoError(err)
}
func (s *userStreamTestSuite) TestCloseUserStream() {
data := []byte(`{}`)
s.mockDo(data, nil)
defer s.assertDo()
listenKey := "dummykey"
s.assertReq(func(r *request) {
s.assertRequestEqual(newRequest().setParam("listenKey", listenKey), r)
})
err := s.client.NewCloseUserStream().ListenKey(listenKey).Do(newContext())
s.r().NoError(err)
}