refac: repository updates, image attachment and deletes report the domain not-found error for an unknown id, the same for articles, users and images, and the test fakes stop returning GORM errors

This commit is contained in:
fsylvain committed 2026-09-23 22:09:06 +02:00
1 parent 4278d96882
commit 6a2ca07b66
14 files changed
+553 -66

No files matched your search

+6 -5
View File
@@ -6,8 +6,6 @@ import (
"errors"
"sort"
"testing"
"gorm.io/gorm"
)
type stubHasher struct {
@@ -106,6 +104,9 @@ func (m *mockUserRepo) Delete(id uint32) error {
if err := m.fail.trigger("Delete"); err != nil {
return err
}
if _, ok := m.users[id]; !ok {
return user.ErrUserNotFound
}
delete(m.users, id)
return nil
}
@@ -116,7 +117,7 @@ func (m *mockUserRepo) UpdateVerificationStatus(userId uint32, isVerified bool)
}
u, ok := m.users[userId]
if !ok {
return user.User{}, gorm.ErrRecordNotFound
return user.User{}, user.ErrUserNotFound
}
u.IsVerified = isVerified
m.users[userId] = u
@@ -129,7 +130,7 @@ func (m *mockUserRepo) UpdatePassword(userId uint32, password string) (user.User
}
u, ok := m.users[userId]
if !ok {
return user.User{}, gorm.ErrRecordNotFound
return user.User{}, user.ErrUserNotFound
}
u.Password = password
m.users[userId] = u
@@ -142,7 +143,7 @@ func (m *mockUserRepo) UpdatePasswordResetCode(userId uint32, code string) (user
}
u, ok := m.users[userId]
if !ok {
return user.User{}, gorm.ErrRecordNotFound
return user.User{}, user.ErrUserNotFound
}
u.PasswordResetCode = code
m.users[userId] = u