mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-14 07:26:47 +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
36 lines
660 B
Go
36 lines
660 B
Go
package main
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
|
|
"github.com/thrasher-corp/gocryptotrader/exchanges/futures"
|
|
)
|
|
|
|
var (
|
|
errInvalidPair = errors.New("invalid currency pair supplied")
|
|
errInvalidAsset = errors.New("invalid asset supplied")
|
|
)
|
|
|
|
func validPair(pair string) bool {
|
|
return strings.Contains(pair, pairDelimiter)
|
|
}
|
|
|
|
func validAsset(i string) bool {
|
|
_, err := asset.New(i)
|
|
return err == nil
|
|
}
|
|
|
|
func isFuturesAsset(a string) error {
|
|
i, err := asset.New(a)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if !i.IsFutures() {
|
|
return fmt.Errorf("%w %q", futures.ErrNotFuturesAsset, a)
|
|
}
|
|
return nil
|
|
}
|