Skip to content

Conversation

@gustaavik
Copy link
Member

This pull request introduces several changes across different areas of the codebase, including modifications to the seeding logic, adjustments to the Cart repository methods in tests, and updates to the Discount use 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:

  • Commented out the seeding logic for orders and payment transactions in cmd/seed/main.go, likely as part of a temporary or debugging measure.
  • Refactored the attributes field in seedProductVariants from a map[string]string to a []map[string]string to better support structured attribute data. This change affects multiple locations in the cmd/seed/main.go file. [1] [2] [3] [4] [5] [6] [7]

Changes to Cart repository methods in tests:

Updates to Discount use case tests:

  • Updated the initialization of mock.NewMockOrderRepository in internal/application/usecase/discount_usecase_test.go to include a false parameter, likely to control specific behavior in the mock implementation. [1] [2] [3] [4] [5] [6] [7] [8]

@gustaavik gustaavik requested a review from Copilot May 13, 2025 11:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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) {

@gustaavik gustaavik merged commit 8bfccee into main May 13, 2025
4 checks passed
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.

2 participants