mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
check env vars for query related tests
This commit is contained in:
parent
062f9243c6
commit
35da3ba3a0
|
@ -2,13 +2,21 @@ package binance
|
|||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestExchange_QueryTickers_AllSymbols(t *testing.T) {
|
||||
e := New("mock_key", "mock_secret")
|
||||
key := os.Getenv("BINANCE_API_KEY")
|
||||
secret := os.Getenv("BINANCE_API_SECRET")
|
||||
if len(key) == 0 && len(secret) == 0 {
|
||||
t.Skip("api key/secret are not configured")
|
||||
return
|
||||
}
|
||||
|
||||
e := New(key, secret)
|
||||
got, err := e.QueryTickers(context.Background())
|
||||
if assert.NoError(t, err) {
|
||||
assert.True(t, len(got) > 1, "binance: attempting to get all symbol tickers, but get 1 or less")
|
||||
|
@ -16,7 +24,14 @@ func TestExchange_QueryTickers_AllSymbols(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestExchange_QueryTickers_SomeSymbols(t *testing.T) {
|
||||
e := New("mock_key", "mock_secret")
|
||||
key := os.Getenv("BINANCE_API_KEY")
|
||||
secret := os.Getenv("BINANCE_API_SECRET")
|
||||
if len(key) == 0 && len(secret) == 0 {
|
||||
t.Skip("api key/secret are not configured")
|
||||
return
|
||||
}
|
||||
|
||||
e := New(key, secret)
|
||||
got, err := e.QueryTickers(context.Background(), "BTCUSDT", "ETHUSDT")
|
||||
if assert.NoError(t, err) {
|
||||
assert.Len(t, got, 2, "binance: attempting to get two symbols, but number of tickers do not match")
|
||||
|
@ -24,7 +39,14 @@ func TestExchange_QueryTickers_SomeSymbols(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestExchange_QueryTickers_SingleSymbol(t *testing.T) {
|
||||
e := New("mock_key", "mock_secret")
|
||||
key := os.Getenv("BINANCE_API_KEY")
|
||||
secret := os.Getenv("BINANCE_API_SECRET")
|
||||
if len(key) == 0 && len(secret) == 0 {
|
||||
t.Skip("api key/secret are not configured")
|
||||
return
|
||||
}
|
||||
|
||||
e := New(key, secret)
|
||||
got, err := e.QueryTickers(context.Background(), "BTCUSDT")
|
||||
if assert.NoError(t, err) {
|
||||
assert.Len(t, got, 1, "binance: attempting to get one symbol, but number of tickers do not match")
|
||||
|
|
|
@ -2,13 +2,21 @@ package max
|
|||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestExchange_QueryTickers_AllSymbols(t *testing.T) {
|
||||
e := New("mock_key", "mock_secret")
|
||||
key := os.Getenv("MAX_API_KEY")
|
||||
secret := os.Getenv("MAX_API_SECRET")
|
||||
if len(key) == 0 && len(secret) == 0 {
|
||||
t.Skip("api key/secret are not configured")
|
||||
return
|
||||
}
|
||||
|
||||
e := New(key, secret)
|
||||
got, err := e.QueryTickers(context.Background())
|
||||
if assert.NoError(t, err) {
|
||||
assert.True(t, len(got) > 1, "max: attempting to get all symbol tickers, but get 1 or less")
|
||||
|
@ -16,7 +24,15 @@ func TestExchange_QueryTickers_AllSymbols(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestExchange_QueryTickers_SomeSymbols(t *testing.T) {
|
||||
e := New("mock_key", "mock_secret")
|
||||
key := os.Getenv("MAX_API_KEY")
|
||||
secret := os.Getenv("MAX_API_SECRET")
|
||||
if len(key) == 0 && len(secret) == 0 {
|
||||
t.Skip("api key/secret are not configured")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
e := New(key, secret)
|
||||
got, err := e.QueryTickers(context.Background(), "BTCUSDT", "ETHUSDT")
|
||||
if assert.NoError(t, err) {
|
||||
assert.Len(t, got, 2, "max: attempting to get two symbols, but number of tickers do not match")
|
||||
|
@ -24,7 +40,14 @@ func TestExchange_QueryTickers_SomeSymbols(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestExchange_QueryTickers_SingleSymbol(t *testing.T) {
|
||||
e := New("mock_key", "mock_secret")
|
||||
key := os.Getenv("MAX_API_KEY")
|
||||
secret := os.Getenv("MAX_API_SECRET")
|
||||
if len(key) == 0 && len(secret) == 0 {
|
||||
t.Skip("api key/secret are not configured")
|
||||
return
|
||||
}
|
||||
|
||||
e := New(key, secret)
|
||||
got, err := e.QueryTickers(context.Background(), "BTCUSDT")
|
||||
if assert.NoError(t, err) {
|
||||
assert.Len(t, got, 1, "max: attempting to get 1 symbols, but number of tickers do not match")
|
||||
|
|
Loading…
Reference in New Issue
Block a user