mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
* GHA, tests: Add additional checks for common issues These checks include: - Ensuring that all testify funcs use their formatted variants (e.g., `assert.Equalf(t, expected, actual)` instead of `assert.Equal(t, expected, actual)`). - Replacing `%s` with %q - Enforcing consistent usage of should/must wording for testify assert/require messages * Add support for checking backticked string format specifiers and fix issues * tests: Fix error comparisons * tests: Replace errors.Is(err, nil) usage with testify and automate check * refactor: Rename ExtractPort to ExtractPortOrDefault * tests: Replace assert with require for error handling in multiple test files * tests: Replace assert with require for error handling and improve assertions in data tests * tests: Fix typo in assertion message for StreamVol test * OKX: Fix GetOpenInterestAndVolumeStrike test with instrument selection and improved assertions * OKX: Revert intentional error check * Improve error message for expiry time check in GetOpenInterestAndVolumeStrike test
53 lines
1.4 KiB
Go
53 lines
1.4 KiB
Go
//go:build mock_test_off
|
|
|
|
// This will build if build tag mock_test_off is parsed and will do live testing
|
|
// using all tests in (exchange)_test.go
|
|
package binance
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
"os"
|
|
"testing"
|
|
|
|
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
|
|
"github.com/thrasher-corp/gocryptotrader/exchanges/sharedtestvalues"
|
|
testexch "github.com/thrasher-corp/gocryptotrader/internal/testing/exchange"
|
|
)
|
|
|
|
var mockTests = false
|
|
|
|
func TestMain(m *testing.M) {
|
|
b = new(Binance)
|
|
if err := testexch.Setup(b); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
if apiKey != "" && apiSecret != "" {
|
|
b.API.AuthenticatedSupport = true
|
|
b.API.CredentialsValidator.RequiresBase64DecodeSecret = false
|
|
b.SetCredentials(apiKey, apiSecret, "", "", "", "")
|
|
}
|
|
|
|
if useTestNet {
|
|
for k, v := range map[exchange.URL]string{
|
|
exchange.RestUSDTMargined: testnetFutures,
|
|
exchange.RestCoinMargined: testnetFutures,
|
|
exchange.RestSpot: testnetSpotURL,
|
|
} {
|
|
if err := b.API.Endpoints.SetRunning(k.String(), v); err != nil {
|
|
log.Fatalf("Testnet %q URL error with %q: %s", k, v, err)
|
|
}
|
|
}
|
|
}
|
|
|
|
b.setupOrderbookManager()
|
|
b.Websocket.DataHandler = sharedtestvalues.GetWebsocketInterfaceChannelOverride()
|
|
log.Printf(sharedtestvalues.LiveTesting, b.Name)
|
|
if err := b.UpdateTradablePairs(context.Background(), true); err != nil {
|
|
log.Fatal("Binance setup error", err)
|
|
}
|
|
|
|
os.Exit(m.Run())
|
|
}
|