Better testing environment changes#24
Merged
Merged
Conversation
…or variant retrieval
…repository to handle shipping details
…in payment handlers
Contributor
There was a problem hiding this comment.
Pull Request Overview
This pull request refactors several components in the testing environment and repository layers to improve clarity and maintainability. Key changes include switching product variant attributes from maps to slices of maps in the seeding logic, updating repository interfaces and method signatures (including switching from CreateWithID to Create in cart tests), and enhancing mock behaviors in discount use case tests.
Reviewed Changes
Copilot reviewed 43 out of 43 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/infrastructure/repository/postgres/product_variant_repository.go | Refactored attribute marshalling/unmarshalling and added duplicate SKU error handling. |
| internal/infrastructure/repository/postgres/product_repository.go | Updated GetByIDWithVariants to use consistent naming and integrated new counting methods. |
| internal/infrastructure/repository/postgres/order_repository.go | Extended order methods with additional fields and improved error handling. |
| internal/infrastructure/payment/* | Added ForceApprovePayment methods across payment services. |
| internal/application/usecase/* | Updated use case signatures and validation logic, including shipping method validations and payment capture enhancements. |
| internal/application/usecase/*_test.go | Updated test mocks and repository method calls (replacing CreateWithID with Create). |
| cmd/seed/main.go | Commented out order and payment transaction seeding and updated product variant seeding to support structured attributes. |
Comments suppressed due to low confidence (1)
internal/infrastructure/repository/postgres/product_repository.go:215
- [nitpick] Ensure that the naming conventions for product identifiers are consistent across repository methods; using 'productId' here improves clarity compared to a generic 'id'.
func (r *ProductRepository) GetByIDWithVariants(productId uint) (*entity.Product, error) {
…failures without interrupting the flow
…ping methods to enhance clarity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several changes across different areas of the codebase, including modifications to the seeding logic, adjustments to the
Cartrepository methods in tests, and updates to theDiscountuse case tests. The most significant updates involve refactoring the structure of product variant attributes, replacing a repository method in test cases, and enhancing the mock order repository initialization.Changes to seeding logic:
cmd/seed/main.go, likely as part of a temporary or debugging measure.attributesfield inseedProductVariantsfrom amap[string]stringto a[]map[string]stringto better support structured attribute data. This change affects multiple locations in thecmd/seed/main.gofile. [1] [2] [3] [4] [5] [6] [7]Changes to
Cartrepository methods in tests:cartRepo.CreateWithIDwithcartRepo.Createin various test cases ininternal/application/usecase/cart_usecase_test.go, simplifying the repository interface and aligning it with the standardCreatemethod. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18]Updates to
Discountuse case tests:mock.NewMockOrderRepositoryininternal/application/usecase/discount_usecase_test.goto include afalseparameter, likely to control specific behavior in the mock implementation. [1] [2] [3] [4] [5] [6] [7] [8]