From 28134c101cc625617b65642806c20ee7ebabef8d Mon Sep 17 00:00:00 2001 From: Kharec Date: Fri, 21 Nov 2025 16:48:15 +0100 Subject: [PATCH] feat: add GetVoteCountsByPostID to the mock for testing --- internal/testutils/mocks.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/internal/testutils/mocks.go b/internal/testutils/mocks.go index 3b0e3af..834369d 100644 --- a/internal/testutils/mocks.go +++ b/internal/testutils/mocks.go @@ -965,6 +965,25 @@ func (m *MockVoteRepository) CountByUserID(userID uint) (int64, error) { 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) { m.mu.RLock() defer m.mu.RUnlock()