Skip to content

feat: implement provide profile availability #477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Smartdevs17
Copy link

Description

This PR updates the test utilities to support the new provider availability model, as part of the migration from a boolean is_available field to a currency-specific available_for array. All test helpers and test data creation now use available_for (an array of ISO currency codes) to set and assert provider availability. This aligns the test setup with the new business logic, ensuring that providers can be tested for availability on a per-currency basis.

Key changes:

  • Removes all usage of IsAvailable and the is_available field from test helpers.
  • Adds and uses AvailableFor and the available_for field for currency-specific provider availability.
  • Updates the default payloads and test assertions to use available_for as an array of ISO currency codes.
  • Ensures all test data and assertions reflect the new provider availability model.

This change is required for the new matching logic and API, and ensures that tests accurately reflect the updated provider profile structure.

References

Testing

  • All unit and integration tests have been updated to use the new available_for field.

  • Manual testing:

    • Run all tests to ensure they pass with the new provider availability logic.
    • Verify that test providers can be created with specific available currencies and that this is reflected in test assertions.
  • Developed and tested on Go 1.21, Postgres 14, MacOS 14, and Docker Compose environment.

  • This change adds test coverage for new/changed/fixed functionality

Checklist

  • I have added documentation and tests for new/changed functionality in this PR
  • All active GitHub checks for tests, formatting, and security are passing
  • The correct base branch is being used, if not main

By submitting a PR, I agree to Paycrest's Contributor Code of Conduct and Contribution Guide.

@Smartdevs17 Smartdevs17 requested review from chibie and 5ran6 as code owners May 31, 2025 00:50
Copy link
Contributor

@chibie chibie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for this PR!

requested minor changes to clean up

Comment on lines +1126 to +1127
// Remove: providerprofile.IsAvailableEQ(true),
// Add: providerprofile.AvailableForContains(institution.Edges.FiatCurrency.Code),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comment

Comment on lines +65 to +66
// Remove: providerprofile.IsAvailable(true),
// The currency filter will be handled in CreatePriorityQueueForBucket
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comment

Comment on lines +540 to +541
// Remove: providerprofile.IsAvailableEQ(true),
// Add: providerprofile.AvailableForContains(bucketCurrency.Code),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comment

Comment on lines +1345 to +1346
// providerprofile.IsAvailableEQ(true), // REMOVE this line
providerprofile.AvailableForContains(currency.Code), // ADD this line
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comments

Comment on lines +477 to +478
// .SetIsAvailable(payload["is_available"].(bool)). // REMOVE this line
SetAvailableFor(payload["available_for"].([]string)). // ADD this line
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comments

@@ -457,7 +457,7 @@ func CreateTestProviderProfile(overrides map[string]interface{}) (*ent.ProviderP
"provision_mode": "auto",
"is_partner": false,
"visibility_mode": "public",
"is_available": true,
"available_for": []string{"USD"}, // <-- Use available_for instead of is_available
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comments

@@ -876,7 +876,7 @@ func (s *IndexerService) IndexOrderRefundedTron(ctx context.Context, order *ent.
logger.WithFields(logger.Fields{
"Error": fmt.Sprintf("%v", err),
"TxHash": order.TxHash,
}).Errorf("Failed to fetch event logs for %s", order.Edges.Token.Edges.Network.Identifier)
}).Errorf("Failed to fetch trx info by id for %s", order.Edges.Token.Edges.Network.Identifier)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert indexer change

@@ -885,7 +885,7 @@ func (s *IndexerService) IndexOrderRefundedTron(ctx context.Context, order *ent.
logger.WithFields(logger.Fields{
"Error": fmt.Sprintf("%v", err),
"Response": data,
}).Errorf("Failed to parse JSON response for %s after fetching event logs", order.Edges.Token.Edges.Network.Identifier)
}).Errorf("Failed to parse JSON response for %s", order.Edges.Token.Edges.Network.Identifier)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert indexer change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update Provider Profile Availability to be Currency-Specific
2 participants