golangci-lint: Enable usetesting and unused linters (#1893)

* golangci-lint: Enable usetesting and unused linters

* tests: Improve assertions in various test cases for clarity and accuracy

* tests: Enhance error assertions in TestExecuteStrategyFromFile for improved clarity

* tests: Update assertions for improved clarity and accuracy

* tests: Replace assert with require for task count checks

* config/versions/v7: Replace context.Background() with t.Context()

* Bithumb: Centralise and consoliate testPair, relax UpdateTickers check

with some glorious Doom Eternal music

* Bithumb: Use UpdatePairsOnce and update remaining pair string

* Bithumb: Add UpdatePairsOnce to TestUpdateTickers
This commit is contained in:
Adrian Gallagher
2025-05-01 14:44:29 +10:00
committed by GitHub
parent c2d876d8b0
commit bea16af380
69 changed files with 3253 additions and 3681 deletions

View File

@@ -89,7 +89,7 @@ func TestExchange_Ticker(t *testing.T) {
if err != nil {
t.Fatal(err)
}
_, err = exchangeTest.Ticker(context.Background(), exchName, c, assetType)
_, err = exchangeTest.Ticker(t.Context(), exchName, c, assetType)
if err != nil {
t.Fatal(err)
}
@@ -101,7 +101,7 @@ func TestExchange_Orderbook(t *testing.T) {
if err != nil {
t.Fatal(err)
}
_, err = exchangeTest.Orderbook(context.Background(), exchName, c, assetType)
_, err = exchangeTest.Orderbook(t.Context(), exchName, c, assetType)
if err != nil {
t.Fatal(err)
}
@@ -123,7 +123,7 @@ func TestExchange_AccountInformation(t *testing.T) {
if !configureExchangeKeys() {
t.Skip("no exchange configured test skipped")
}
_, err := exchangeTest.AccountInformation(context.Background(),
_, err := exchangeTest.AccountInformation(t.Context(),
exchName, asset.Spot)
if err != nil {
t.Fatal(err)
@@ -135,7 +135,7 @@ func TestExchange_QueryOrder(t *testing.T) {
t.Skip("no exchange configured test skipped")
}
t.Parallel()
_, err := exchangeTest.QueryOrder(context.Background(),
_, err := exchangeTest.QueryOrder(t.Context(),
exchName, orderID, currency.EMPTYPAIR, assetType)
if err != nil {
t.Fatal(err)
@@ -162,7 +162,7 @@ func TestExchange_SubmitOrder(t *testing.T) {
Exchange: exchName,
AssetType: asset.Spot,
}
_, err = exchangeTest.SubmitOrder(context.Background(), tempOrder)
_, err = exchangeTest.SubmitOrder(t.Context(), tempOrder)
if err != nil {
t.Fatal(err)
}
@@ -175,7 +175,7 @@ func TestExchange_CancelOrder(t *testing.T) {
t.Parallel()
cp := currency.NewPair(currency.BTC, currency.USD)
a := asset.Spot
_, err := exchangeTest.CancelOrder(context.Background(),
_, err := exchangeTest.CancelOrder(t.Context(),
exchName, orderID, cp, a)
if err != nil {
t.Fatal(err)
@@ -186,7 +186,7 @@ func TestOHLCV(t *testing.T) {
t.Parallel()
cp := currency.NewPair(currency.BTC, currency.AUD)
cp.Delimiter = currency.DashDelimiter
calvinKline, err := exchangeTest.OHLCV(context.Background(), exchName, cp, assetType, time.Now().Add(-time.Hour*24).UTC(), time.Now().UTC(), kline.OneHour)
calvinKline, err := exchangeTest.OHLCV(t.Context(), exchName, cp, assetType, time.Now().Add(-time.Hour*24).UTC(), time.Now().UTC(), kline.OneHour)
if err != nil {
t.Error(err)
}

View File

@@ -1,7 +1,6 @@
package validator
import (
"context"
"testing"
"time"
@@ -64,13 +63,13 @@ func TestWrapper_IsEnabled(t *testing.T) {
func TestWrapper_AccountInformation(t *testing.T) {
t.Parallel()
_, err := testWrapper.AccountInformation(context.Background(),
_, err := testWrapper.AccountInformation(t.Context(),
exchName, asset.Spot)
if err != nil {
t.Fatal(err)
}
_, err = testWrapper.AccountInformation(context.Background(),
_, err = testWrapper.AccountInformation(t.Context(),
exchError.String(), asset.Spot)
if err == nil {
t.Fatal("expected AccountInformation to return error on invalid name")
@@ -80,31 +79,31 @@ func TestWrapper_AccountInformation(t *testing.T) {
func TestWrapper_CancelOrder(t *testing.T) {
t.Parallel()
cp := currency.NewPair(currency.BTC, currency.USD)
_, err := testWrapper.CancelOrder(context.Background(),
_, err := testWrapper.CancelOrder(t.Context(),
exchName, orderID, cp, assetType)
if err != nil {
t.Error(err)
}
_, err = testWrapper.CancelOrder(context.Background(),
_, err = testWrapper.CancelOrder(t.Context(),
exchError.String(), orderID, cp, assetType)
if err == nil {
t.Error("expected CancelOrder to return error on invalid name")
}
_, err = testWrapper.CancelOrder(context.Background(),
_, err = testWrapper.CancelOrder(t.Context(),
exchName, "", cp, assetType)
if err == nil {
t.Error("expected CancelOrder to return error on invalid name")
}
_, err = testWrapper.CancelOrder(context.Background(),
_, err = testWrapper.CancelOrder(t.Context(),
exchName, orderID, currency.EMPTYPAIR, assetType)
if err != nil {
t.Error(err)
}
_, err = testWrapper.CancelOrder(context.Background(),
_, err = testWrapper.CancelOrder(t.Context(),
exchName, orderID, cp, asset.Empty)
if err != nil {
t.Error(err)
@@ -129,13 +128,13 @@ func TestWrapper_Orderbook(t *testing.T) {
if err != nil {
t.Fatal(err)
}
_, err = testWrapper.Orderbook(context.Background(),
_, err = testWrapper.Orderbook(t.Context(),
exchName, c, assetType)
if err != nil {
t.Fatal(err)
}
_, err = testWrapper.Orderbook(context.Background(),
_, err = testWrapper.Orderbook(t.Context(),
exchError.String(), currencyPair, asset.Spot)
if err == nil {
t.Fatal("expected Orderbook to return error with invalid name")
@@ -162,13 +161,13 @@ func TestWrapper_Pairs(t *testing.T) {
func TestWrapper_QueryOrder(t *testing.T) {
t.Parallel()
_, err := testWrapper.QueryOrder(context.Background(),
_, err := testWrapper.QueryOrder(t.Context(),
exchName, orderID, currency.EMPTYPAIR, assetType)
if err != nil {
t.Fatal(err)
}
_, err = testWrapper.QueryOrder(context.Background(),
_, err = testWrapper.QueryOrder(t.Context(),
exchError.String(), "", currency.EMPTYPAIR, assetType)
if err == nil {
t.Fatal("expected QueryOrder to return error on invalid name")
@@ -191,12 +190,12 @@ func TestWrapper_SubmitOrder(t *testing.T) {
Exchange: "true",
AssetType: asset.Spot,
}
_, err = testWrapper.SubmitOrder(context.Background(), tempOrder)
_, err = testWrapper.SubmitOrder(t.Context(), tempOrder)
if err != nil {
t.Fatal(err)
}
_, err = testWrapper.SubmitOrder(context.Background(), nil)
_, err = testWrapper.SubmitOrder(t.Context(), nil)
if err == nil {
t.Fatal("expected SubmitOrder to return error with invalid name")
}
@@ -208,25 +207,25 @@ func TestWrapper_Ticker(t *testing.T) {
if err != nil {
t.Fatal(err)
}
_, err = testWrapper.Ticker(context.Background(), exchName, c, assetType)
_, err = testWrapper.Ticker(t.Context(), exchName, c, assetType)
if err != nil {
t.Fatal(err)
}
_, err = testWrapper.Ticker(context.Background(), exchError.String(), currencyPair, asset.Spot)
_, err = testWrapper.Ticker(t.Context(), exchError.String(), currencyPair, asset.Spot)
if err == nil {
t.Fatal("expected Ticker to return error with invalid name")
}
}
func TestWrapper_WithdrawalCryptoFunds(t *testing.T) {
_, err := testWrapper.WithdrawalCryptoFunds(context.Background(),
_, err := testWrapper.WithdrawalCryptoFunds(t.Context(),
&withdraw.Request{Exchange: exchError.String()})
if err == nil {
t.Fatal("expected WithdrawalCryptoFunds to return error with invalid name")
}
_, err = testWrapper.WithdrawalCryptoFunds(context.Background(),
_, err = testWrapper.WithdrawalCryptoFunds(t.Context(),
&withdraw.Request{Exchange: exchName})
if err != nil {
t.Fatal("expected WithdrawalCryptoFunds to return error with invalid name")
@@ -234,13 +233,13 @@ func TestWrapper_WithdrawalCryptoFunds(t *testing.T) {
}
func TestWrapper_WithdrawalFiatFunds(t *testing.T) {
_, err := testWrapper.WithdrawalFiatFunds(context.Background(),
_, err := testWrapper.WithdrawalFiatFunds(t.Context(),
"", &withdraw.Request{Exchange: exchError.String()})
if err == nil {
t.Fatal("expected WithdrawalFiatFunds to return error with invalid name")
}
_, err = testWrapper.WithdrawalFiatFunds(context.Background(),
_, err = testWrapper.WithdrawalFiatFunds(t.Context(),
"", &withdraw.Request{Exchange: exchName})
if err != nil {
t.Fatal("expected WithdrawalCryptoFunds to return error with invalid name")
@@ -252,12 +251,12 @@ func TestWrapper_OHLCV(t *testing.T) {
if err != nil {
t.Fatal(err)
}
_, err = testWrapper.OHLCV(context.Background(),
_, err = testWrapper.OHLCV(t.Context(),
"test", c, asset.Spot, time.Now().Add(-24*time.Hour), time.Now(), kline.OneDay)
if err != nil {
t.Fatal(err)
}
_, err = testWrapper.OHLCV(context.Background(),
_, err = testWrapper.OHLCV(t.Context(),
exchError.String(), c, asset.Spot,
time.Now().Add(-24*time.Hour),
time.Now(), kline.OneDay)