feat: add GetVoteCountsByPostID to the mock for testing

This commit is contained in:
2025-11-21 16:48:15 +01:00
parent 2f78370d43
commit 28134c101c

View File

@@ -965,6 +965,25 @@ func (m *MockVoteRepository) CountByUserID(userID uint) (int64, error) {
return count, nil return count, nil
} }
func (m *MockVoteRepository) GetVoteCountsByPostID(postID uint) (int, int, error) {
m.mu.RLock()
defer m.mu.RUnlock()
upVotes := 0
downVotes := 0
for _, vote := range m.votes {
if vote.PostID == postID {
switch vote.Type {
case database.VoteUp:
upVotes++
case database.VoteDown:
downVotes++
}
}
}
return upVotes, downVotes, nil
}
func (m *MockVoteRepository) Count() (int64, error) { func (m *MockVoteRepository) Count() (int64, error) {
m.mu.RLock() m.mu.RLock()
defer m.mu.RUnlock() defer m.mu.RUnlock()