-
Notifications
You must be signed in to change notification settings - Fork 2
/
user_stream_service_test.go
61 lines (47 loc) · 1.48 KB
/
user_stream_service_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
package binance
import (
"testing"
"github.com/crypto-zero/go-binance/v2/common"
"github.com/stretchr/testify/suite"
)
type userStreamServiceTestSuite struct {
baseTestSuite
}
func TestUserStreamService(t *testing.T) {
suite.Run(t, new(userStreamServiceTestSuite))
}
func (s *userStreamServiceTestSuite) TestStartUserStream() {
data := []byte(`{
"listenKey": "pqia91ma19a5s61cv6a81va65sdf19v8a65a1a5s61cv6a81va65sdf19v8a65a1"
}`)
s.mockDo(data, nil)
defer s.assertDo()
s.assertReq(func(r *common.Request) {
s.assertRequestEqual(newRequest(), r)
})
listenKey, err := s.client.NewStartUserStreamService().Do(newContext())
s.r().NoError(err)
s.r().Equal("pqia91ma19a5s61cv6a81va65sdf19v8a65a1a5s61cv6a81va65sdf19v8a65a1", listenKey)
}
func (s *userStreamServiceTestSuite) TestKeepaliveUserStream() {
data := []byte(`{}`)
s.mockDo(data, nil)
defer s.assertDo()
listenKey := "dummykey"
s.assertReq(func(r *common.Request) {
s.assertRequestEqual(newRequest().SetForm("listenKey", listenKey), r)
})
err := s.client.NewKeepaliveUserStreamService().ListenKey(listenKey).Do(newContext())
s.r().NoError(err)
}
func (s *userStreamServiceTestSuite) TestCloseUserStream() {
data := []byte(`{}`)
s.mockDo(data, nil)
defer s.assertDo()
listenKey := "dummykey"
s.assertReq(func(r *common.Request) {
s.assertRequestEqual(newRequest().SetForm("listenKey", listenKey), r)
})
err := s.client.NewCloseUserStreamService().ListenKey(listenKey).Do(newContext())
s.r().NoError(err)
}