Dirty implementation of createVotes

This commit is contained in:
2025-01-08 13:57:49 +01:00
parent ca824726b4
commit 49a1df06d2
7 changed files with 223 additions and 17 deletions

View File

@ -15,6 +15,7 @@ func newTestApplication(t *testing.T) *application {
logger: slog.New(slog.NewTextHandler(io.Discard, nil)),
elections: &mockElectionModel{},
voters: &mockVoterModel{},
votes: &mockVoteModel{},
}
}
@ -56,8 +57,8 @@ func (e *mockElectionModel) GetById(id int) (*models.Election, error) {
Tokens: 100,
AreVotersKnown: false,
MaxVoters: 10,
CreatedAt: time.Now().String(),
ExpiresAt: time.Now().Add(100 * time.Hour).String(),
CreatedAt: time.Now(),
ExpiresAt: time.Now().Add(100 * time.Hour),
}, nil
}
@ -67,3 +68,22 @@ type mockVoterModel struct {
func (v *mockVoterModel) Insert(identity string, electionID int) (int, error) {
return 1, nil
}
func (v *mockVoterModel) CountByElection(electionID int) (int, error) {
return 10, nil
}
func (v *mockVoterModel) Exists(voterIdentity string, electionID int) (bool, error) {
return true, nil
}
type mockVoteModel struct {
}
func (v *mockVoteModel) Insert(voterIdentity string, electionId int, choiceText string, tokens int) (int, error) {
return 1, nil
}
func (v *mockVoteModel) Exists(voterIdentity string, electionID int) (bool, error) {
return true, nil
}