-
-
Notifications
You must be signed in to change notification settings - Fork 71
/
v5_user_service_test.go
70 lines (62 loc) · 1.72 KB
/
v5_user_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
62
63
64
65
66
67
68
69
70
package bybit
import (
"encoding/json"
"net/http"
"testing"
"github.com/hirokisan/bybit/v2/testhelper"
"github.com/stretchr/testify/require"
)
func TestV5User_GetAPIKey(t *testing.T) {
t.Run("success", func(t *testing.T) {
path := "/v5/user/query-api"
method := http.MethodGet
status := http.StatusOK
respBody := map[string]interface{}{
"result": map[string]interface{}{
"id": "16651472",
"note": "testxxx",
"apiKey": "opjSlSOzqIeXROT5rq",
"readOnly": 0,
"secret": "",
"permissions": map[string]interface{}{
"ContractTrade": []interface{}{},
"Spot": []interface{}{},
"Wallet": []interface{}{
"AccountTransfer",
},
"Options": []interface{}{},
"Derivatives": []interface{}{},
"CopyTrading": []interface{}{},
"BlockTrade": []interface{}{},
"Exchange": []interface{}{},
"NFT": []interface{}{},
},
"ips": []interface{}{"*"},
"type": 1,
"deadlineDay": 88,
"expiredAt": "2023-05-15T03:13:24Z",
"createdAt": "2023-02-15T03:13:24Z",
"unified": 0,
"uta": 0,
"userID": 53888001,
"inviterID": 0,
"vipLevel": "No VIP",
"mktMakerLevel": "0",
"affiliateID": 0,
},
}
bytesBody, err := json.Marshal(respBody)
require.NoError(t, err)
server, teardown := testhelper.NewServer(
testhelper.WithHandlerOption(path, method, status, bytesBody),
)
defer teardown()
client := NewTestClient().
WithBaseURL(server.URL).
WithAuth("test", "test")
resp, err := client.V5().User().GetAPIKey()
require.NoError(t, err)
require.NotNil(t, resp)
testhelper.Compare(t, respBody["result"], resp.Result)
})
}