fix(tests): update mock repo to match interface
This commit is contained in:
parent
51a8293a11
commit
e64b3a4855
2 changed files with 68 additions and 24 deletions
|
|
@ -22,6 +22,7 @@ type MockRepository struct {
|
|||
users []domain.User
|
||||
orders []domain.Order
|
||||
shipping []domain.ShippingMethod
|
||||
shippingSettings map[uuid.UUID]domain.ShippingSettings
|
||||
}
|
||||
|
||||
func NewMockRepository() *MockRepository {
|
||||
|
|
@ -31,6 +32,7 @@ func NewMockRepository() *MockRepository {
|
|||
users: make([]domain.User, 0),
|
||||
orders: make([]domain.Order, 0),
|
||||
shipping: make([]domain.ShippingMethod, 0),
|
||||
shippingSettings: make(map[uuid.UUID]domain.ShippingSettings),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -274,6 +276,26 @@ func (m *MockRepository) UpsertShippingMethods(ctx context.Context, methods []do
|
|||
return nil
|
||||
}
|
||||
|
||||
func (m *MockRepository) GetShippingSettings(ctx context.Context, vendorID uuid.UUID) (*domain.ShippingSettings, error) {
|
||||
if s, ok := m.shippingSettings[vendorID]; ok {
|
||||
return &s, nil
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (m *MockRepository) UpsertShippingSettings(ctx context.Context, settings *domain.ShippingSettings) error {
|
||||
m.shippingSettings[settings.VendorID] = *settings
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MockRepository) ListReviews(ctx context.Context, filter domain.ReviewFilter) ([]domain.Review, int64, error) {
|
||||
return []domain.Review{}, 0, nil
|
||||
}
|
||||
|
||||
func (m *MockRepository) ListShipments(ctx context.Context, filter domain.ShipmentFilter) ([]domain.Shipment, int64, error) {
|
||||
return []domain.Shipment{}, 0, nil
|
||||
}
|
||||
|
||||
// MockPaymentGateway implements the PaymentGateway interface for testing
|
||||
type MockPaymentGateway struct{}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ type MockRepository struct {
|
|||
cartItems []domain.CartItem
|
||||
reviews []domain.Review
|
||||
shipping []domain.ShippingMethod
|
||||
shippingSettings map[uuid.UUID]domain.ShippingSettings
|
||||
}
|
||||
|
||||
func NewMockRepository() *MockRepository {
|
||||
|
|
@ -29,6 +30,7 @@ func NewMockRepository() *MockRepository {
|
|||
cartItems: make([]domain.CartItem, 0),
|
||||
reviews: make([]domain.Review, 0),
|
||||
shipping: make([]domain.ShippingMethod, 0),
|
||||
shippingSettings: make(map[uuid.UUID]domain.ShippingSettings),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -293,6 +295,26 @@ func (m *MockRepository) UpsertShippingMethods(ctx context.Context, methods []do
|
|||
return nil
|
||||
}
|
||||
|
||||
func (m *MockRepository) GetShippingSettings(ctx context.Context, vendorID uuid.UUID) (*domain.ShippingSettings, error) {
|
||||
if s, ok := m.shippingSettings[vendorID]; ok {
|
||||
return &s, nil
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (m *MockRepository) UpsertShippingSettings(ctx context.Context, settings *domain.ShippingSettings) error {
|
||||
m.shippingSettings[settings.VendorID] = *settings
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MockRepository) ListReviews(ctx context.Context, filter domain.ReviewFilter) ([]domain.Review, int64, error) {
|
||||
return m.reviews, int64(len(m.reviews)), nil
|
||||
}
|
||||
|
||||
func (m *MockRepository) ListShipments(ctx context.Context, filter domain.ShipmentFilter) ([]domain.Shipment, int64, error) {
|
||||
return []domain.Shipment{}, 0, nil
|
||||
}
|
||||
|
||||
// MockPaymentGateway for testing
|
||||
type MockPaymentGateway struct{}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue