From fbaf66ab426f7d637955321ccf07213a9da5078b Mon Sep 17 00:00:00 2001 From: Gareth Kirwan Date: Wed, 30 Oct 2024 13:04:54 +0700 Subject: [PATCH] fixup! Huobi: assertify tests --- exchanges/credentials.go | 4 ++-- exchanges/credentials_test.go | 8 ++++---- exchanges/huobi/huobi_test.go | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/exchanges/credentials.go b/exchanges/credentials.go index 56c9d80dd8c..86f2324f63c 100644 --- a/exchanges/credentials.go +++ b/exchanges/credentials.go @@ -22,7 +22,7 @@ var ( // undertake an authenticated HTTP request. ErrCredentialsAreEmpty = errors.New("credentials are empty") // Errors related to API requirements and failures - errRequiresAPIKey = errors.New("requires API key but default/empty one set") + ErrRequiresAPIKey = errors.New("requires API key but default/empty one set") errRequiresAPISecret = errors.New("requires API secret but default/empty one set") errRequiresAPIPEMKey = errors.New("requires API PEM key but default/empty one set") errRequiresAPIClientID = errors.New("requires API Client ID but default/empty one set") @@ -152,7 +152,7 @@ func (b *Base) VerifyAPICredentials(creds *account.Credentials) error { } if b.API.CredentialsValidator.RequiresKey && (creds.Key == "" || creds.Key == config.DefaultAPIKey) { - return fmt.Errorf("%s %w", b.Name, errRequiresAPIKey) + return fmt.Errorf("%s %w", b.Name, ErrRequiresAPIKey) } if b.API.CredentialsValidator.RequiresSecret && diff --git a/exchanges/credentials_test.go b/exchanges/credentials_test.go index 0e7f5e721ec..9a256251300 100644 --- a/exchanges/credentials_test.go +++ b/exchanges/credentials_test.go @@ -20,8 +20,8 @@ func TestGetCredentials(t *testing.T) { b.API.CredentialsValidator.RequiresKey = true ctx := account.DeployCredentialsToContext(context.Background(), &account.Credentials{Secret: "wow"}) _, err = b.GetCredentials(ctx) - if !errors.Is(err, errRequiresAPIKey) { - t.Fatalf("received: %v but expected: %v", err, errRequiresAPIKey) + if !errors.Is(err, ErrRequiresAPIKey) { + t.Fatalf("received: %v but expected: %v", err, ErrRequiresAPIKey) } b.API.CredentialsValidator.RequiresSecret = true @@ -165,7 +165,7 @@ func TestVerifyAPICredentials(t *testing.T) { // Empty credentials {Expected: ErrCredentialsAreEmpty}, // test key - {RequiresKey: true, Expected: errRequiresAPIKey, Secret: "bruh"}, + {RequiresKey: true, Expected: ErrRequiresAPIKey, Secret: "bruh"}, {RequiresKey: true, Key: "k3y"}, // test secret {RequiresSecret: true, Expected: errRequiresAPISecret, Key: "bruh"}, @@ -246,7 +246,7 @@ func TestCheckCredentials(t *testing.T) { credentials: account.Credentials{OneTimePassword: "wow"}, }, }, - expectedErr: errRequiresAPIKey, + expectedErr: ErrRequiresAPIKey, }, { name: "Test exchange usage with authenticated API support disabled, but with valid credentials", diff --git a/exchanges/huobi/huobi_test.go b/exchanges/huobi/huobi_test.go index 72a21a78853..79f24d5bb24 100644 --- a/exchanges/huobi/huobi_test.go +++ b/exchanges/huobi/huobi_test.go @@ -1157,7 +1157,7 @@ func TestGetActiveOrders(t *testing.T) { if sharedtestvalues.AreAPICredentialsSet(h) { require.NoError(t, err) } else { - require.ErrorIs(t, err, exchange.ErrCredentialsAreEmpty) + require.ErrorIs(t, err, exchange.ErrRequiresAPIKey) } }