diff --git a/pkg/exchange/binance/ticker_test.go b/pkg/exchange/binance/ticker_test.go index 9d85de607..3bdee463c 100644 --- a/pkg/exchange/binance/ticker_test.go +++ b/pkg/exchange/binance/ticker_test.go @@ -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") diff --git a/pkg/exchange/max/ticker_test.go b/pkg/exchange/max/ticker_test.go index e0d5dab9a..68defb2f6 100644 --- a/pkg/exchange/max/ticker_test.go +++ b/pkg/exchange/max/ticker_test.go @@ -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")