add tests for repository
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s

This commit is contained in:
Thomas Peetz
2026-10-06 17:11:42 +02:00
parent 32f3f034eb
commit 980eda29af
9 changed files with 154 additions and 17 deletions
+14 -6
View File
@@ -17,13 +17,21 @@ func NewSportRepository(db *gorm.DB) *SportRepository {
return repo
}
func (repository *SportRepository) FindAll(context context.Context) ([]models.Sport, error) {
var sports []models.Sport
func (repository *SportRepository) FindAll(page int, limit int, context context.Context) (sports []models.Sport, total int64, err error) {
offset := (page - 1) * limit
result := repository.db.Find(&sports)
slog.Info("SportRepository#FindAll", "count", result.RowsAffected)
return sports, nil
err = repository.db.
Model(&models.Sport{}).
Count(&total).
Limit(limit).
Offset(offset).
Order("id asc").
Find(&sports).Error
if err != nil {
return
}
slog.Info("SportRepository#FindAll", "total", total)
return
}
func (repository *SportRepository) GetById(context context.Context, id string) (models.Sport, error) {