Fix maxVoters check and add unit tests
This commit is contained in:
@ -82,7 +82,7 @@ func TestCreateElection(t *testing.T) {
|
||||
Choices: []string{"Gandhi", "Buddha"},
|
||||
ExpiresAt: time.Now().Add(24 * time.Hour),
|
||||
AreVotersKnown: false,
|
||||
MaxVoters: 10,
|
||||
MaxVoters: 1000,
|
||||
Name: "Guy of the year",
|
||||
Tokens: 100,
|
||||
},
|
||||
@ -179,6 +179,19 @@ func TestCreateElection(t *testing.T) {
|
||||
},
|
||||
expectedCode: http.StatusUnprocessableEntity,
|
||||
},
|
||||
{
|
||||
name: "Invalid request for known voters election (max voters greater than 100)",
|
||||
urlPath: path,
|
||||
body: api.CreateElectionRequest{
|
||||
Choices: []string{"Gandhi", "Buddha", ""},
|
||||
ExpiresAt: time.Now().Add(24 * time.Hour),
|
||||
AreVotersKnown: true,
|
||||
MaxVoters: 101,
|
||||
Name: "Guy of the year",
|
||||
Tokens: 100,
|
||||
},
|
||||
expectedCode: http.StatusUnprocessableEntity,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
Reference in New Issue
Block a user