Tests: Abstract UpdatePairsOnce (#1503)

This commit is contained in:
Gareth Kirwan
2024-03-15 06:37:06 +01:00
committed by GitHub
parent 9d1476d4f1
commit 3e4b9becfe
5 changed files with 36 additions and 52 deletions

View File

@@ -7,7 +7,6 @@ import (
"log"
"os"
"strconv"
"sync"
"testing"
"time"
@@ -27,6 +26,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/exchanges/stream"
"github.com/thrasher-corp/gocryptotrader/exchanges/subscription"
"github.com/thrasher-corp/gocryptotrader/exchanges/ticker"
testexch "github.com/thrasher-corp/gocryptotrader/internal/testing/exchange"
"github.com/thrasher-corp/gocryptotrader/portfolio/withdraw"
)
@@ -152,17 +152,7 @@ func TestGetPairs(t *testing.T) {
func TestUpdateTradablePairs(t *testing.T) {
t.Parallel()
updatePairsOnce(t)
}
var updatePairsGuard sync.Once
func updatePairsOnce(tb testing.TB) {
tb.Helper()
updatePairsGuard.Do(func() {
err := b.UpdateTradablePairs(context.Background(), true)
assert.NoError(tb, err, "UpdateTradablePairs should not error")
})
testexch.UpdatePairsOnce(t, b)
}
func TestUpdateOrderExecutionLimits(t *testing.T) {
@@ -557,7 +547,7 @@ func TestUpdateTicker(t *testing.T) {
func TestUpdateTickers(t *testing.T) {
t.Parallel()
updatePairsOnce(t)
testexch.UpdatePairsOnce(t, b)
assets := b.GetAssetTypes(false)
for _, a := range assets {