-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathapi_test.go
83 lines (74 loc) · 1.52 KB
/
api_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
71
72
73
74
75
76
77
78
79
80
81
82
83
package bitmex
import (
"github.com/micro/go-micro/config"
"github.com/micro/go-micro/config/source/file"
"testing"
)
var (
_proxyURL string
_testnet bool
_key string
_secret string
_key2 string
_secret2 string
)
func loadConfig() {
err := config.Load(file.NewSource(file.WithPath("./testdata/config.yaml")))
if err != nil {
return
}
cfg := config.Map()
_proxyURL = cfg["proxy_url"].(string)
_testnet = cfg["testnet"].(bool)
_key = cfg["key"].(string)
_secret = cfg["secret"].(string)
_key2 = cfg["key2"].(string)
_secret2 = cfg["secret2"].(string)
}
func TestConfig(t *testing.T) {
err := config.Load(file.NewSource(file.WithPath("./testdata/config.yaml")))
if err != nil {
t.Error(err)
}
cfg := config.Map()
proxy := cfg["proxy_url"].(string)
testnet := cfg["testnet"].(bool)
key := cfg["key"].(string)
secret := cfg["secret"].(string)
key2 := cfg["key2"].(string)
secret2 := cfg["secret2"].(string)
t.Log(proxy)
t.Log(testnet)
t.Log(key)
t.Log(secret)
t.Log(key2)
t.Log(secret2)
}
func newBitmexForTest() *BitMEX {
loadConfig()
var host string
if _testnet {
host = HostTestnet
} else {
host = HostReal
}
bitmex := New(nil, host, _key, _secret, true)
if _proxyURL != "" {
bitmex.SetHttpProxy(_proxyURL)
}
return bitmex
}
func newBitmexForTest2() *BitMEX {
loadConfig()
var host string
if _testnet {
host = HostTestnet
} else {
host = HostReal
}
bitmex := New(nil, host, _key2, _secret2, true)
if _proxyURL != "" {
bitmex.SetHttpProxy(_proxyURL)
}
return bitmex
}