- Rename catalog: ingredient/* → product/* (canonical_name, barcode, nutrition per 100g)
- Rename pantry: product/* → userproduct/* (user-owned items with expiry)
- Squash migrations into single 001_initial_schema.sql (clean-db baseline)
- product_categories: add English canonical name column; fix COALESCE in queries
- Remove product_translations: product names are stored in their original language
- Add default_unit_name to product API responses via unit_translations JOIN
- Add cmd/importoff: bulk import from OpenFoodFacts JSONL dump (COPY + ON CONFLICT)
- Diary: support product_id entries alongside dish_id (CHECK num_nonnulls = 1)
- Home: getLoggedCalories joins both recipes and catalog products
- Flutter: rename models/providers/services to match backend rename
- Flutter: add barcode scan flow for diary (mobile_scanner, product_portion_sheet)
- Flutter: localise 6 new keys across 12 languages (barcode scan, portion weight)
- Routes: GET /products/search, GET /products/barcode/{barcode}, /user-products
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
37 lines
1.6 KiB
Go
37 lines
1.6 KiB
Go
package mocks
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/food-ai/backend/internal/domain/userproduct"
|
|
)
|
|
|
|
// MockUserProductRepository is a test double implementing userproduct.UserProductRepository.
|
|
type MockUserProductRepository struct {
|
|
ListFn func(ctx context.Context, userID string) ([]*userproduct.UserProduct, error)
|
|
CreateFn func(ctx context.Context, userID string, req userproduct.CreateRequest) (*userproduct.UserProduct, error)
|
|
BatchCreateFn func(ctx context.Context, userID string, items []userproduct.CreateRequest) ([]*userproduct.UserProduct, error)
|
|
UpdateFn func(ctx context.Context, id, userID string, req userproduct.UpdateRequest) (*userproduct.UserProduct, error)
|
|
DeleteFn func(ctx context.Context, id, userID string) error
|
|
}
|
|
|
|
func (m *MockUserProductRepository) List(ctx context.Context, userID string) ([]*userproduct.UserProduct, error) {
|
|
return m.ListFn(ctx, userID)
|
|
}
|
|
|
|
func (m *MockUserProductRepository) Create(ctx context.Context, userID string, req userproduct.CreateRequest) (*userproduct.UserProduct, error) {
|
|
return m.CreateFn(ctx, userID, req)
|
|
}
|
|
|
|
func (m *MockUserProductRepository) BatchCreate(ctx context.Context, userID string, items []userproduct.CreateRequest) ([]*userproduct.UserProduct, error) {
|
|
return m.BatchCreateFn(ctx, userID, items)
|
|
}
|
|
|
|
func (m *MockUserProductRepository) Update(ctx context.Context, id, userID string, req userproduct.UpdateRequest) (*userproduct.UserProduct, error) {
|
|
return m.UpdateFn(ctx, id, userID, req)
|
|
}
|
|
|
|
func (m *MockUserProductRepository) Delete(ctx context.Context, id, userID string) error {
|
|
return m.DeleteFn(ctx, id, userID)
|
|
}
|