Skip to content

Commit

Permalink
fixup! Huobi: assertify tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gbjk committed Oct 30, 2024
1 parent d226051 commit fbaf66a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions exchanges/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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 &&
Expand Down
8 changes: 4 additions & 4 deletions exchanges/credentials_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"},
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion exchanges/huobi/huobi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down

0 comments on commit fbaf66a

Please sign in to comment.