Dirty implementation of createVotes
This commit is contained in:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user