mirror of
https://github.com/SamyRai/tercul-backend.git
synced 2025-12-27 05:11:34 +00:00
Some checks failed
- Updated database models and repositories to replace uint IDs with UUIDs. - Modified test fixtures to generate and use UUIDs for authors, translations, users, and works. - Adjusted mock implementations to align with the new UUID structure. - Ensured all relevant functions and methods are updated to handle UUIDs correctly. - Added necessary imports for UUID handling in various files.
96 lines
3.8 KiB
Go
96 lines
3.8 KiB
Go
package translation
|
|
|
|
import (
|
|
"context"
|
|
"gorm.io/gorm"
|
|
"tercul/internal/domain"
|
|
)
|
|
|
|
type mockTranslationRepository struct {
|
|
domain.TranslationRepository
|
|
getByIDFunc func(ctx context.Context, id uint) (*domain.Translation, error)
|
|
listByWorkIDPaginatedFunc func(ctx context.Context, workID uint, language *string, page, pageSize int) (*domain.PaginatedResult[domain.Translation], error)
|
|
}
|
|
|
|
func (m *mockTranslationRepository) GetByID(ctx context.Context, id uuid.UUID) (*domain.Translation, error) {
|
|
if m.getByIDFunc != nil {
|
|
return m.getByIDFunc(ctx, id)
|
|
}
|
|
return nil, nil
|
|
}
|
|
|
|
func (m *mockTranslationRepository) ListByWorkIDPaginated(ctx context.Context, workID uint, language *string, page, pageSize int) (*domain.PaginatedResult[domain.Translation], error) {
|
|
if m.listByWorkIDPaginatedFunc != nil {
|
|
return m.listByWorkIDPaginatedFunc(ctx, workID, language, page, pageSize)
|
|
}
|
|
return nil, nil
|
|
}
|
|
|
|
// Implement other methods of the interface if needed for tests, returning nil or default values.
|
|
func (m *mockTranslationRepository) Create(ctx context.Context, entity *domain.Translation) error {
|
|
return nil
|
|
}
|
|
func (m *mockTranslationRepository) CreateInTx(ctx context.Context, tx *gorm.DB, entity *domain.Translation) error {
|
|
return nil
|
|
}
|
|
func (m *mockTranslationRepository) GetByIDWithOptions(ctx context.Context, id uint, options *domain.QueryOptions) (*domain.Translation, error) {
|
|
return nil, nil
|
|
}
|
|
func (m *mockTranslationRepository) Update(ctx context.Context, entity *domain.Translation) error {
|
|
return nil
|
|
}
|
|
func (m *mockTranslationRepository) UpdateInTx(ctx context.Context, tx *gorm.DB, entity *domain.Translation) error {
|
|
return nil
|
|
}
|
|
func (m *mockTranslationRepository) Delete(ctx context.Context, id uint) error {
|
|
return nil
|
|
}
|
|
func (m *mockTranslationRepository) DeleteInTx(ctx context.Context, tx *gorm.DB, id uint) error {
|
|
return nil
|
|
}
|
|
func (m *mockTranslationRepository) List(ctx context.Context, page, pageSize int) (*domain.PaginatedResult[domain.Translation], error) {
|
|
return nil, nil
|
|
}
|
|
func (m *mockTranslationRepository) ListWithOptions(ctx context.Context, options *domain.QueryOptions) ([]domain.Translation, error) {
|
|
return nil, nil
|
|
}
|
|
func (m *mockTranslationRepository) ListAll(ctx context.Context) ([]domain.Translation, error) {
|
|
return nil, nil
|
|
}
|
|
func (m *mockTranslationRepository) Count(ctx context.Context) (int64, error) {
|
|
return 0, nil
|
|
}
|
|
func (m *mockTranslationRepository) CountWithOptions(ctx context.Context, options *domain.QueryOptions) (int64, error) {
|
|
return 0, nil
|
|
}
|
|
func (m *mockTranslationRepository) FindWithPreload(ctx context.Context, preloads []string, id uint) (*domain.Translation, error) {
|
|
return nil, nil
|
|
}
|
|
func (m *mockTranslationRepository) GetAllForSync(ctx context.Context, batchSize, offset int) ([]domain.Translation, error) {
|
|
return nil, nil
|
|
}
|
|
func (m *mockTranslationRepository) Exists(ctx context.Context, id uint) (bool, error) {
|
|
return false, nil
|
|
}
|
|
func (m *mockTranslationRepository) BeginTx(ctx context.Context) (*gorm.DB, error) {
|
|
return nil, nil
|
|
}
|
|
func (m *mockTranslationRepository) WithTx(ctx context.Context, fn func(tx *gorm.DB) error) error {
|
|
return nil
|
|
}
|
|
func (m *mockTranslationRepository) ListByWorkID(ctx context.Context, workID uint) ([]domain.Translation, error) {
|
|
return nil, nil
|
|
}
|
|
func (m *mockTranslationRepository) ListByEntity(ctx context.Context, entityType string, entityID uint) ([]domain.Translation, error) {
|
|
return nil, nil
|
|
}
|
|
func (m *mockTranslationRepository) ListByTranslatorID(ctx context.Context, translatorID uint) ([]domain.Translation, error) {
|
|
return nil, nil
|
|
}
|
|
func (m *mockTranslationRepository) ListByStatus(ctx context.Context, status domain.TranslationStatus) ([]domain.Translation, error) {
|
|
return nil, nil
|
|
}
|
|
func (m *mockTranslationRepository) Upsert(ctx context.Context, translation *domain.Translation) error {
|
|
return nil
|
|
}
|