golangci-lint: Bump to v2.0.2 and fix issues (#1871)

* build(deps): Bump golangci/golangci-lint-action from 6 to 7

Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 6 to 7.
- [Release notes](https://github.com/golangci/golangci-lint-action/releases)
- [Commits](https://github.com/golangci/golangci-lint-action/compare/v6...v7)

---
updated-dependencies:
- dependency-name: golangci/golangci-lint-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* golangci-lint: Bump to v2 and fix issues

* refactor: remove no longer need ifshort nolint directives, fix test grammar and improve for loop logic

* nits: update order pair handling in tests and improve string replacement logic

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
This commit is contained in:
dependabot[bot]
2025-04-02 15:36:05 +11:00
committed by GitHub
parent 1b7fa2259a
commit 179519a3c3
45 changed files with 342 additions and 304 deletions

View File

@@ -2445,17 +2445,22 @@ func (b *Binance) GetFuturesPositionSummary(ctx context.Context, req *futures.Po
}
var c currency.Code
if collateralMode == collateral.SingleMode {
switch collateralMode {
case collateral.SingleMode:
var collateralAsset *UAsset
if strings.Contains(accountPosition.Symbol, usdtAsset.Asset) {
switch {
case strings.Contains(accountPosition.Symbol, usdtAsset.Asset):
collateralAsset = usdtAsset
} else if strings.Contains(accountPosition.Symbol, busdAsset.Asset) {
case strings.Contains(accountPosition.Symbol, busdAsset.Asset):
collateralAsset = busdAsset
}
collateralTotal = collateralAsset.WalletBalance
collateralAvailable = collateralAsset.AvailableBalance
unrealisedPNL = collateralAsset.UnrealizedProfit
c = currency.NewCode(collateralAsset.Asset)
if marginType == margin.Multi {
isolatedMargin = collateralAsset.CrossUnPnl
collateralUsed = collateralTotal + isolatedMargin
@@ -2463,7 +2468,8 @@ func (b *Binance) GetFuturesPositionSummary(ctx context.Context, req *futures.Po
isolatedMargin = accountPosition.IsolatedWallet
collateralUsed = isolatedMargin
}
} else if collateralMode == collateral.MultiMode {
case collateral.MultiMode:
collateralTotal = ai.TotalWalletBalance
collateralUsed = ai.TotalWalletBalance - ai.AvailableBalance
collateralAvailable = ai.AvailableBalance

View File

@@ -807,13 +807,11 @@ func (bi *Binanceus) GetUsersSpotAssetSnapshot(ctx context.Context, startTime, e
params := url.Values{}
params.Set("type", "SPOT")
params.Set("timestamp", strconv.FormatInt(time.Now().UnixMilli(), 10))
if !(startTime.IsZero() && startTime.Unix() <= 0) && startTime.Before(time.Now()) {
if !startTime.IsZero() {
params.Set("startTime", strconv.FormatInt(startTime.UnixMilli(), 10))
}
if !(endTime.IsZero() && endTime.Unix() <= 0) && endTime.After(time.Now()) {
if (params.Get("startTime") != "" && endTime.After(startTime)) || params.Get("startTime") == "" {
params.Set("endTime", strconv.FormatInt(endTime.UnixMilli(), 10))
}
if !endTime.IsZero() {
params.Set("endTime", strconv.FormatInt(endTime.UnixMilli(), 10))
}
if limit > 0 {
params.Set("limit", strconv.FormatUint(limit, 10))
@@ -1728,7 +1726,7 @@ func (bi *Binanceus) GetSubAccountDepositHistory(ctx context.Context, email stri
func (bi *Binanceus) GetReferralRewardHistory(ctx context.Context, userBusinessType, page, rows int) (*ReferralRewardHistoryResponse, error) {
params := url.Values{}
switch {
case !(userBusinessType == 0 || userBusinessType == 1):
case userBusinessType != 0 && userBusinessType != 1:
return nil, errInvalidUserBusinessType
case page == 0:
return nil, errMissingPageNumber

View File

@@ -210,31 +210,34 @@ func TestSubmitOrder(t *testing.T) {
func TestCancelOrder(t *testing.T) {
t.Parallel()
sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders)
pair := currency.NewPair(currency.BTC, currency.USD)
err := bi.CancelOrder(context.Background(), &order.Cancel{
AssetType: asset.Spot,
OrderID: "1337",
})
if err != nil && !errors.Is(err, errMissingCurrencySymbol) {
t.Error("Binanceus CancelOrder() error", err)
}
require.ErrorIs(t, err, errMissingCurrencySymbol)
err = bi.CancelOrder(context.Background(), &order.Cancel{
AssetType: asset.Futures,
OrderID: "69",
Pair: pair,
})
require.ErrorIs(t, err, asset.ErrNotSupported)
err = bi.CancelOrder(context.Background(), &order.Cancel{
AssetType: asset.Spot,
Pair: currency.NewPair(currency.BTC, currency.USDT),
OrderID: "",
Pair: pair,
})
if err != nil && !(errors.Is(err, errEitherOrderIDOrClientOrderIDIsRequired) || strings.Contains(err.Error(), "ID not set")) {
t.Errorf("Binanceus CancelOrder() expecting %v, but found %v", errEitherOrderIDOrClientOrderIDIsRequired, err)
}
require.ErrorIs(t, err, order.ErrOrderIDNotSet)
sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders)
cancellationOrder := &order.Cancel{
OrderID: "1",
Pair: pair,
AssetType: asset.Spot,
}
err = bi.CancelOrder(context.Background(), cancellationOrder)
if err != nil && !strings.Contains(err.Error(), "Unknown order sent.") {
t.Error("Binanceus CancelOrder() error", err)
}
assert.ErrorContains(t, err, "Unknown order sent.")
}
func TestCancelAllOrders(t *testing.T) {
@@ -701,16 +704,14 @@ func TestGetReferralRewardHistory(t *testing.T) {
func TestGetSubaccountTransferHistory(t *testing.T) {
t.Parallel()
sharedtestvalues.SkipTestIfCredentialsUnset(t, bi)
_, er := bi.GetSubaccountTransferHistory(context.Background(), "", 0, 0, 0, 0)
if !errors.Is(er, errNotValidEmailAddress) {
t.Errorf("Binanceus GetSubaccountTransferHistory() expected %v, but received: %s", errNotValidEmailAddress, er)
}
_, err := bi.GetSubaccountTransferHistory(context.Background(), "", 0, 0, 0, 0)
assert.ErrorIs(t, err, errNotValidEmailAddress)
sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders)
_, er = bi.GetSubaccountTransferHistory(context.Background(), "example@golang.org", 0, 0, 0, 0)
if er != nil && !(errors.Is(er, errNotValidEmailAddress) || strings.Contains(er.Error(), "Sub-account function is not enabled.")) {
t.Fatalf("Binanceus GetSubaccountTransferHistory() error %v", er)
}
_, err = bi.GetSubaccountTransferHistory(context.Background(), "example@golang.org", 0, 0, 0, 0)
assert.Error(t, err, "GetSubaccountTransferHistory should return an error on a bogus email")
}
func TestExecuteSubAccountTransfer(t *testing.T) {
@@ -871,18 +872,21 @@ func TestGetAllOpenOrders(t *testing.T) {
func TestCancelExistingOrder(t *testing.T) {
t.Parallel()
_, err := bi.CancelExistingOrder(context.Background(), &CancelOrderRequestParams{})
assert.ErrorIs(t, err, errMissingCurrencySymbol)
_, err = bi.CancelExistingOrder(context.Background(), &CancelOrderRequestParams{
Symbol: currency.NewBTCUSDT(),
})
assert.ErrorIs(t, err, errEitherOrderIDOrClientOrderIDIsRequired)
sharedtestvalues.SkipTestIfCredentialsUnset(t, bi, canManipulateRealOrders)
_, er := bi.CancelExistingOrder(context.Background(), &CancelOrderRequestParams{Symbol: currency.NewPair(currency.BTC, currency.USDT)})
if er != nil && !errors.Is(er, errEitherOrderIDOrClientOrderIDIsRequired) {
t.Errorf("Binanceus CancelExistingOrder() error expecting %v, but found %v", errEitherOrderIDOrClientOrderIDIsRequired, er)
}
_, er = bi.CancelExistingOrder(context.Background(), &CancelOrderRequestParams{
Symbol: currency.NewPair(currency.BTC, currency.USDT),
_, err = bi.CancelExistingOrder(context.Background(), &CancelOrderRequestParams{
Symbol: currency.NewBTCUSDT(),
ClientSuppliedOrderID: "1234",
})
if er != nil && !strings.Contains(er.Error(), "Unknown order sent.") {
t.Error("Binanceus CancelExistingorder() error", er)
}
assert.ErrorContains(t, err, "Unknown order sent.")
}
func TestCancelOpenOrdersForSymbol(t *testing.T) {

View File

@@ -1135,10 +1135,11 @@ func (b *Bitfinex) fixCasing(in currency.Pair, a asset.Item) (string, error) {
in = in.Lower()
var checkString [2]byte
if a == asset.Spot || a == asset.Margin {
switch a {
case asset.Spot, asset.Margin:
checkString[0] = 't'
checkString[1] = 'T'
} else if a == asset.MarginFunding {
case asset.MarginFunding:
checkString[0] = 'f'
checkString[1] = 'F'
}

View File

@@ -528,11 +528,13 @@ func (b *Bithumb) GetOrderInfo(ctx context.Context, orderID string, pair currenc
Pair: pair,
}
if orders.Data[i].Type == "bid" {
switch orders.Data[i].Type {
case "bid":
orderDetail.Side = order.Buy
} else if orders.Data[i].Type == "ask" {
case "ask":
orderDetail.Side = order.Sell
}
return &orderDetail, nil
}
return nil, fmt.Errorf("%w %v", order.ErrOrderNotFound, orderID)
@@ -661,9 +663,10 @@ func (b *Bithumb) GetActiveOrders(ctx context.Context, req *order.MultiOrderRequ
format.Delimiter),
}
if resp.Data[i].Type == "bid" {
switch resp.Data[i].Type {
case "bid":
orderDetail.Side = order.Buy
} else if resp.Data[i].Type == "ask" {
case "ask":
orderDetail.Side = order.Sell
}
@@ -716,9 +719,10 @@ func (b *Bithumb) GetOrderHistory(ctx context.Context, req *order.MultiOrderRequ
format.Delimiter),
}
if resp.Data[i].Type == "bid" {
switch resp.Data[i].Type {
case "bid":
orderDetail.Side = order.Buy
} else if resp.Data[i].Type == "ask" {
case "ask":
orderDetail.Side = order.Sell
}

View File

@@ -295,12 +295,12 @@ func (b *BTSE) wsHandleData(respRaw []byte) error {
}
var price, amount float64
for i := range t.Data.SellQuote {
p := strings.Replace(t.Data.SellQuote[i].Price, ",", "", -1)
p := strings.ReplaceAll(t.Data.SellQuote[i].Price, ",", "")
price, err = strconv.ParseFloat(p, 64)
if err != nil {
return err
}
a := strings.Replace(t.Data.SellQuote[i].Size, ",", "", -1)
a := strings.ReplaceAll(t.Data.SellQuote[i].Size, ",", "")
amount, err = strconv.ParseFloat(a, 64)
if err != nil {
return err
@@ -314,12 +314,12 @@ func (b *BTSE) wsHandleData(respRaw []byte) error {
})
}
for j := range t.Data.BuyQuote {
p := strings.Replace(t.Data.BuyQuote[j].Price, ",", "", -1)
p := strings.ReplaceAll(t.Data.BuyQuote[j].Price, ",", "")
price, err = strconv.ParseFloat(p, 64)
if err != nil {
return err
}
a := strings.Replace(t.Data.BuyQuote[j].Size, ",", "", -1)
a := strings.ReplaceAll(t.Data.BuyQuote[j].Size, ",", "")
amount, err = strconv.ParseFloat(a, 64)
if err != nil {
return err

View File

@@ -546,12 +546,14 @@ func (b *BTSE) CancelAllOrders(ctx context.Context, orderCancellation *order.Can
}
func orderIntToType(i int) order.Type {
if i == 77 {
switch i {
case 77:
return order.Market
} else if i == 76 {
case 76:
return order.Limit
default:
return order.UnknownType
}
return order.UnknownType
}
// GetOrderInfo returns order information based on order ID
@@ -764,12 +766,7 @@ func (b *BTSE) GetActiveOrders(ctx context.Context, req *order.MultiOrderRequest
Side: side,
Price: resp[i].Price,
Status: status,
}
if resp[i].OrderType == 77 {
openOrder.Type = order.Market
} else if resp[i].OrderType == 76 {
openOrder.Type = order.Limit
Type: orderIntToType(resp[i].OrderType),
}
fills, err := b.TradeHistory(ctx,

View File

@@ -1187,7 +1187,7 @@ func (by *Bybit) ConstructOrderDetails(tradeOrders []TradeOrder, assetType asset
return nil, err
}
if (pair.IsEmpty() && len(filterPairs) > 0 && !filterPairs.Contains(ePair, true)) ||
!(pair.IsEmpty() || pair.Equal(ePair)) {
(!pair.IsEmpty() && !pair.Equal(ePair)) {
continue
}
orderType, err := order.StringToOrderType(tradeOrders[x].OrderType)

View File

@@ -2841,7 +2841,7 @@ func (d *Deribit) optionPairToString(pair currency.Pair) string {
initialDelimiter = currency.UnderscoreDelimiter
// Replace a capital D with d for decimal place in Strike price
// Char 11 is either the hyphen before Strike price or first digit
q = q[:11] + strings.Replace(q[11:], "D", "d", -1)
q = q[:11] + strings.Replace(q[11:], "D", "d", 1)
}
return pair.Base.String() + initialDelimiter + q
}

View File

@@ -684,7 +684,9 @@ func (d *Deribit) processOrderbook(respRaw []byte, channels []string) error {
if len(asks) == 0 && len(bids) == 0 {
return nil
}
if orderbookData.Type == "snapshot" {
switch orderbookData.Type {
case "snapshot":
return d.Websocket.Orderbook.LoadSnapshot(&orderbook.Base{
Exchange: d.Name,
VerifyOrderbook: d.CanVerifyOrderbook,
@@ -695,7 +697,7 @@ func (d *Deribit) processOrderbook(respRaw []byte, channels []string) error {
Asset: a,
LastUpdateID: orderbookData.ChangeID,
})
} else if orderbookData.Type == "change" {
case "change":
return d.Websocket.Orderbook.Update(&orderbook.Update{
Asks: asks,
Bids: bids,

View File

@@ -1301,9 +1301,10 @@ func (d *Deribit) GetFuturesPositionSummary(ctx context.Context, r *futures.Posi
}
var baseSize float64
if r.Asset == asset.Futures {
switch r.Asset {
case asset.Futures:
baseSize = pos[index].SizeCurrency
} else if r.Asset == asset.Options {
case asset.Options:
baseSize = pos[index].Size
}
contractSize = multiplier * baseSize
@@ -1507,10 +1508,7 @@ func (d *Deribit) GetHistoricalFundingRates(ctx context.Context, r *fundingrate.
var fundingRates []fundingrate.Rate
mfr := make(map[int64]struct{})
for {
if ed.Equal(r.StartDate) || ed.Before(r.StartDate) {
break
}
for ed.After(r.StartDate) {
var records []FundingRateHistory
if d.Websocket.IsConnected() {
records, err = d.WSRetrieveFundingRateHistory(p, r.StartDate, ed)

View File

@@ -769,7 +769,7 @@ func TestFormatExchangeCurrencies(t *testing.T) {
assert.Equal(t, "btc~usd^ltc~btc", got)
_, err = e.FormatExchangeCurrencies(nil, asset.Spot)
assert.ErrorContains(t, err, "returned empty string", err, "FormatExchangeCurrencies should error correctly")
assert.ErrorContains(t, err, "returned empty string", "FormatExchangeCurrencies should error correctly")
}
func TestFormatExchangeCurrency(t *testing.T) {

View File

@@ -3667,7 +3667,7 @@ func getCryptocurrencyWithdrawalFee(c currency.Code) float64 {
// GetUnderlyingFromCurrencyPair returns an underlying string from a currency pair
func (g *Gateio) GetUnderlyingFromCurrencyPair(p currency.Pair) (currency.Pair, error) {
pairString := strings.Replace(p.Upper().String(), currency.DashDelimiter, currency.UnderscoreDelimiter, -1)
pairString := strings.ReplaceAll(p.Upper().String(), currency.DashDelimiter, currency.UnderscoreDelimiter)
ccies := strings.Split(pairString, currency.UnderscoreDelimiter)
if len(ccies) < 2 {
return currency.EMPTYPAIR, fmt.Errorf("invalid currency pair %v", p)

View File

@@ -3386,7 +3386,7 @@ func getPair(tb testing.TB, a asset.Item) currency.Pair {
func TestGetClientOrderIDFromText(t *testing.T) {
t.Parallel()
assert.Zero(t, getClientOrderIDFromText("api"), "should not return anything")
assert.Empty(t, getClientOrderIDFromText("api"), "should not return anything")
assert.Equal(t, "t-123", getClientOrderIDFromText("t-123"), "should return t-123")
}

View File

@@ -436,7 +436,7 @@ allTrades:
Timestamp: tradeTS,
})
if i == len(tradeData)-1 {
if ts == tradeTS {
if ts.Equal(tradeTS) {
break allTrades
}
ts = tradeTS
@@ -548,12 +548,17 @@ func (g *Gemini) GetOrderInfo(ctx context.Context, orderID string, _ currency.Pa
if err != nil {
return nil, err
}
var orderType order.Type
if resp.Type == "exchange limit" {
switch resp.Type {
case "exchange limit":
orderType = order.Limit
} else if resp.Type == "market buy" || resp.Type == "market sell" {
case "market buy", "market sell":
orderType = order.Market
default:
return nil, fmt.Errorf("unknown order type: %q", resp.Type)
}
var side order.Side
side, err = order.StringToOrderSide(resp.Side)
if err != nil {
@@ -657,12 +662,17 @@ func (g *Gemini) GetActiveOrders(ctx context.Context, req *order.MultiOrderReque
if err != nil {
return nil, err
}
var orderType order.Type
if resp[i].Type == "exchange limit" {
switch resp[i].Type {
case "exchange limit":
orderType = order.Limit
} else if resp[i].Type == "market buy" || resp[i].Type == "market sell" {
case "market buy", "market sell":
orderType = order.Market
default:
return nil, fmt.Errorf("unknown order type: %q", resp[i].Type)
}
var side order.Side
side, err = order.StringToOrderSide(resp[i].Side)
if err != nil {

View File

@@ -1004,9 +1004,10 @@ func (ku *Kucoin) GetOrderInfo(ctx context.Context, orderID string, pair currenc
if err != nil {
return nil, err
}
if side == order.Sell {
switch side {
case order.Sell:
side = order.Short
} else if side == order.Buy {
case order.Buy:
side = order.Long
}
if !pair.IsEmpty() && !nPair.Equal(pair) {
@@ -1202,7 +1203,7 @@ func (ku *Kucoin) GetActiveOrders(ctx context.Context, getOrdersRequest *order.M
if err != nil {
return nil, err
}
if getOrdersRequest.Validate() != nil {
if err := getOrdersRequest.Validate(); err != nil {
return nil, err
}
format, err := ku.GetPairFormat(getOrdersRequest.AssetType, true)
@@ -1242,15 +1243,19 @@ func (ku *Kucoin) GetActiveOrders(ctx context.Context, getOrdersRequest *order.M
if !enabled {
continue
}
side, err := order.StringToOrderSide(futuresOrders.Items[x].Side)
if err != nil {
return nil, err
}
if side == order.Sell {
switch side {
case order.Sell:
side = order.Short
} else if side == order.Buy {
case order.Buy:
side = order.Long
}
oType, err := order.StringToOrderType(futuresOrders.Items[x].OrderType)
if err != nil {
return nil, fmt.Errorf("asset type: %v order type: %v err: %w", getOrdersRequest.AssetType, getOrdersRequest.Type, err)
@@ -1442,18 +1447,18 @@ func (ku *Kucoin) GetOrderHistory(ctx context.Context, getOrdersRequest *order.M
if getOrdersRequest == nil {
return nil, common.ErrNilPointer
}
err := ku.CurrencyPairs.IsAssetEnabled(getOrdersRequest.AssetType)
if err != nil {
return nil, err
}
if getOrdersRequest.Validate() != nil {
return nil, err
}
var sideString string
sideString, err = ku.OrderSideString(getOrdersRequest.Side)
if err := ku.CurrencyPairs.IsAssetEnabled(getOrdersRequest.AssetType); err != nil {
return nil, err
}
if err := getOrdersRequest.Validate(); err != nil {
return nil, err
}
sideString, err := ku.OrderSideString(getOrdersRequest.Side)
if err != nil {
return nil, err
}
var orders []order.Detail
var orderSide order.Side
var orderStatus order.Status

View File

@@ -79,7 +79,7 @@ func TestString(t *testing.T) {
assert.Equal(t, spotIsolatedStr, SpotIsolated.String())
assert.Equal(t, cashStr, NoMargin.String())
assert.Equal(t, unknownStr, Type(30).String())
assert.Equal(t, "", Unset.String())
assert.Empty(t, Unset.String())
}
func TestUpper(t *testing.T) {

View File

@@ -2333,7 +2333,9 @@ func (ok *Okx) GetFixedLoanBorrowQuote(ctx context.Context, borrowingCurrency cu
if borrowType == "" {
return nil, errBorrowTypeRequired
}
if borrowType == "normal" {
switch borrowType {
case "normal":
if borrowingCurrency.IsEmpty() {
return nil, currency.ErrCurrencyCodeEmpty
}
@@ -2346,11 +2348,12 @@ func (ok *Okx) GetFixedLoanBorrowQuote(ctx context.Context, borrowingCurrency cu
if term == "" {
return nil, errLendingTermIsRequired
}
} else if borrowType == "reborrow" {
case "reborrow":
if orderID == "" {
return nil, order.ErrOrderIDNotSet
}
}
params := url.Values{}
params.Set("type", borrowType)
if !borrowingCurrency.IsEmpty() {

View File

@@ -1751,7 +1751,7 @@ allOrders:
for i := range orderList {
if req.StartTime.Equal(orderList[i].CreationTime.Time()) ||
orderList[i].CreationTime.Time().Before(req.StartTime) ||
endTime == orderList[i].CreationTime.Time() {
endTime.Equal(orderList[i].CreationTime.Time()) {
// reached end of orders to crawl
break allOrders
}
@@ -1899,7 +1899,7 @@ allOrders:
for i := range orderList {
if req.StartTime.Equal(orderList[i].CreationTime.Time()) ||
orderList[i].CreationTime.Time().Before(req.StartTime) ||
endTime == orderList[i].CreationTime.Time() {
endTime.Equal(orderList[i].CreationTime.Time()) {
// reached end of orders to crawl
break allOrders
}
@@ -2224,10 +2224,7 @@ func (ok *Okx) GetHistoricalFundingRates(ctx context.Context, r *fundingrate.His
}
// map of time indexes, allowing for easy lookup of slice index from unix time data
mti := make(map[int64]int)
for {
if sd.Equal(r.EndDate) || sd.After(r.EndDate) {
break
}
for sd.Before(r.EndDate) {
var frh []FundingRateResponse
frh, err = ok.GetFundingRateHistory(ctx, fPair.String(), sd, r.EndDate, int64(requestLimit))
if err != nil {
@@ -2279,10 +2276,7 @@ func (ok *Okx) GetHistoricalFundingRates(ctx context.Context, r *fundingrate.His
if time.Since(r.StartDate) < kline.OneWeek.Duration() {
billDetailsFunc = ok.GetBillsDetailLast7Days
}
for {
if sd.Equal(r.EndDate) || sd.After(r.EndDate) {
break
}
for sd.Before(r.EndDate) {
var fri time.Duration
if len(ok.Features.Supports.FuturesCapabilities.SupportedFundingRateFrequencies) == 1 {
// can infer funding rate interval from the only funding rate frequency defined

View File

@@ -1251,7 +1251,7 @@ func (o *ClassificationError) Error() string {
func (c *Cancel) StandardCancel() validate.Checker {
return validate.Check(func() error {
if c.OrderID == "" {
return errors.New("ID not set")
return ErrOrderIDNotSet
}
return nil
})

View File

@@ -345,9 +345,7 @@ func TestGetOrderTrades(t *testing.T) {
case !sharedtestvalues.AreAPICredentialsSet(p) && err == nil && !mockTests:
t.Error("Expecting an error when no keys are set")
case mockTests && err != nil:
if !(tt.errExpected && strings.Contains(err.Error(), tt.errMsgExpected)) {
t.Errorf("Could not mock get order trades: %s", err)
}
assert.ErrorContains(t, err, tt.errMsgExpected)
}
})
}

View File

@@ -1401,7 +1401,7 @@ func TestRemoveURLQueryString(t *testing.T) {
t.Parallel()
assert.Equal(t, "https://www.google.com", removeURLQueryString("https://www.google.com?test=1"), "removeURLQueryString should remove query string")
assert.Equal(t, "https://www.google.com", removeURLQueryString("https://www.google.com"), "removeURLQueryString should not change URL")
assert.Equal(t, "", removeURLQueryString(""), "removeURLQueryString should be equal")
assert.Empty(t, removeURLQueryString(""), "removeURLQueryString should be empty")
}
func TestWriteToConn(t *testing.T) {

View File

@@ -63,7 +63,7 @@ func TestAdd(t *testing.T) {
require.NoError(t, s.Add(sub), "Should not error on a standard add")
assert.NotNil(t, s.get(sub), "Should have stored the sub")
assert.ErrorIs(t, s.Add(sub), ErrDuplicate, "Should error on duplicates")
assert.NotNil(t, sub.Key, sub, "Add should call EnsureKeyed")
assert.NotNil(t, sub.Key, "Add should call EnsureKeyed")
}
// TestGet exercises Get and get methods