package testutil import ( "context" "fmt" "tercul/internal/domain" "gorm.io/gorm" ) // MockBaseRepository provides common mock implementations for BaseRepository methods type MockBaseRepository[T any] struct { // This is a helper struct that can be embedded in mock repositories // to provide common mock implementations } // BeginTx starts a new transaction (mock implementation) func (m *MockBaseRepository[T]) BeginTx(ctx context.Context) (*gorm.DB, error) { return nil, fmt.Errorf("transactions not supported in mock repository") } // WithTx executes a function within a transaction (mock implementation) func (m *MockBaseRepository[T]) WithTx(ctx context.Context, fn func(tx *gorm.DB) error) error { return fmt.Errorf("transactions not supported in mock repository") } // CreateInTx creates an entity within a transaction (mock implementation) func (m *MockBaseRepository[T]) CreateInTx(ctx context.Context, tx *gorm.DB, entity *T) error { return fmt.Errorf("CreateInTx not implemented in mock repository") } // UpdateInTx updates an entity within a transaction (mock implementation) func (m *MockBaseRepository[T]) UpdateInTx(ctx context.Context, tx *gorm.DB, entity *T) error { return fmt.Errorf("UpdateInTx not implemented in mock repository") } // DeleteInTx removes an entity by its ID within a transaction (mock implementation) func (m *MockBaseRepository[T]) DeleteInTx(ctx context.Context, tx *gorm.DB, id uint) error { return fmt.Errorf("DeleteInTx not implemented in mock repository") } // GetByIDWithOptions retrieves an entity by its ID with query options (mock implementation) func (m *MockBaseRepository[T]) GetByIDWithOptions(ctx context.Context, id uint, options *domain.QueryOptions) (*T, error) { return nil, fmt.Errorf("GetByIDWithOptions not implemented in mock repository") } // ListWithOptions returns entities with query options (mock implementation) func (m *MockBaseRepository[T]) ListWithOptions(ctx context.Context, options *domain.QueryOptions) ([]T, error) { return nil, fmt.Errorf("ListWithOptions not implemented in mock repository") } // CountWithOptions returns the count with query options (mock implementation) func (m *MockBaseRepository[T]) CountWithOptions(ctx context.Context, options *domain.QueryOptions) (int64, error) { return 0, fmt.Errorf("CountWithOptions not implemented in mock repository") } // Exists checks if an entity exists by ID (mock implementation) func (m *MockBaseRepository[T]) Exists(ctx context.Context, id uint) (bool, error) { return false, fmt.Errorf("Exists not implemented in mock repository") } // GetAllForSync returns entities in batches for synchronization (mock implementation) func (m *MockBaseRepository[T]) GetAllForSync(ctx context.Context, batchSize, offset int) ([]T, error) { return nil, fmt.Errorf("GetAllForSync not implemented in mock repository") } // AddMockBaseRepositoryMethods adds all the missing BaseRepository methods to a mock repository // This is a helper function to avoid duplicating code func AddMockBaseRepositoryMethods[T any](repo interface{}) { // This function would use reflection to add methods, but for now // we'll implement them manually in each repository }