common: Replace StringDataCompare with slices.Contains and cleanup string funcs (#1631)

* common: Replace StringDataCompare with slices.Contains and cleanup string funcs

* common/docs: Update SliceDifference and remove outdated steps from ADD_NEW_EXCHANGE.md

* common: Improve SliceDifference
This commit is contained in:
Adrian Gallagher
2024-09-13 10:43:20 +10:00
committed by GitHub
parent 22cb0eb9b9
commit b8e836d74f
32 changed files with 201 additions and 370 deletions

View File

@@ -307,7 +307,7 @@ func checkMissingExchanges() []string {
}
supportedExchs := exchange.Exchanges
for z := 0; z < len(supportedExchs); {
if common.StringDataContainsInsensitive(tempArray, supportedExchs[z]) {
if common.StringSliceContainsInsensitive(tempArray, supportedExchs[z]) {
supportedExchs = append(supportedExchs[:z], supportedExchs[z+1:]...)
continue
}

View File

@@ -5,6 +5,7 @@ import (
"errors"
"os"
"reflect"
"slices"
"strings"
"testing"
"time"
@@ -51,14 +52,14 @@ func TestAllExchangeWrappers(t *testing.T) {
name := strings.ToLower(cfg.Exchanges[i].Name)
t.Run(name+" wrapper tests", func(t *testing.T) {
t.Parallel()
if common.StringDataContains(unsupportedExchangeNames, name) {
if slices.Contains(unsupportedExchangeNames, name) {
t.Skipf("skipping unsupported exchange %v", name)
}
if singleExchangeOverride != "" && name != singleExchangeOverride {
t.Skip("skipping ", name, " due to override")
}
ctx := context.Background()
if isCITest() && common.StringDataContains(blockedCIExchanges, name) {
if isCITest() && slices.Contains(blockedCIExchanges, name) {
// rather than skipping tests where execution is blocked, provide an expired
// context, so no executions can take place
var cancelFn context.CancelFunc